In [1]:
import os
import sys
sys.path.append("..")
sys.path.append("../..")
import pandas as pd
import yellowbrick as yb
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib notebook
In [2]:
DATA = os.path.normpath("../data/")
def load_data(name):
path = os.path.join(DATA, name, name + ".csv")
return pd.read_csv(path)
In [3]:
df = load_data("concrete")
df.head()
Out[3]:
In [4]:
from sklearn.model_selection import train_test_split as tts
features = ["cement", "slag", "ash", "water", "splast", "coarse", "fine", "age"]
target = "strength"
X = df[features]
y = df[target]
X_train, X_test, y_train, y_test = tts(X, y, test_size=0.2)
In [5]:
from sklearn.linear_model import LassoCV
from yellowbrick.regressor import PredictionError
model = PredictionError(LassoCV())
model.fit(X_train, y_train)
model.score(X_test, y_test)
model.show()