text_plain_output_1.png
from sklearn.impute import SimpleImputer

from sklearn.impute import SimpleImputer

from sklearn.metrics import mean_absolute_error

from sklearn.pipeline import Pipeline

from sklearn.preprocessing import OneHotEncoder

import numpy as np

from sklearn.impute import SimpleImputer
numerical_transformer = SimpleImputer(missing_values=np.NaN, strategy='mean')
categorical_transformer = Pipeline(steps=[('imputer', SimpleImputer(strategy='most_frequent')), ('onehot', OneHotEncoder(handle_unknown='ignore'))])

mean_train = np.mean(y_train)
baseline_predictions = np.ones(y_test.shape) * mean_train
mae_baseline = mean_absolute_error(y_test, baseline_predictions)
print('Baseline MAE is {:.2f}'.format(mae_baseline))