text_html_output_2.png
from category_encoders import OneHotEncoder, OrdinalEncoder

from sklearn.impute import SimpleImputer

from sklearn.linear_model import Ridge, LinearRegression

from sklearn.metrics import roc_curve, plot_roc_curve, mean_absolute_error, mean_squared_error, accuracy_score

y_pred = [y_train.mean()] * len(y_train)
mean_baseline_pred = y_train.mean()
baseline_mae = mean_absolute_error(y_train, y_pred)
baseline_rmse = mean_squared_error(y_train, y_pred, squared=False)

onehot = OneHotEncoder(use_cat_names=True)
onehot_fit = onehot.fit(X_train)
XT_train = onehot.transform(X_train)
XT_val = onehot.transform(X_val)
simp = SimpleImputer(strategy='mean')
simp_fit = simp.fit(XT_train)
XT_train = simp.transform(XT_train)
XT_val = simp.transform(XT_val)
model_lr = LinearRegression()
model_r = Ridge()
model_r.fit(XT_train, y_train)
model_lr.fit(XT_train, y_train)
def check_metrics(model):
    print(model)
    print('===================================================================')
    print('Training MAE:', mean_absolute_error(y_train, model.predict(XT_train)))
    print('-------------------------------------------------------------------')
    print('Validation MAE:', mean_absolute_error(y_val, model.predict(XT_val)))
    print('-------------------------------------------------------------------')
    print('Validation R2 score:', model.score(XT_val, y_val))
    print('===================================================================')
model = [model_r, model_lr]
for m in model:
    check_metrics(m)