text_html_output_1.png
from sklearn.ensemble import RandomForestRegressor, BaggingRegressor

from sklearn.metrics import mean_squared_error, mean_absolute_error, accuracy_score

def score_model(model, X_t=X_train, X_v=X_valid, y_t=y_train, y_v=y_valid):
    model.fit(X_t, y_t)
    preds = model.predict(X_v)
    return mean_absolute_error(y_v, preds)

model_1 = RandomForestRegressor(n_estimators=50, random_state=69)
model_2 = RandomForestRegressor(n_estimators=100, random_state=69)
model_3 = RandomForestRegressor(n_estimators=100, criterion='mae', random_state=69)
model_4 = RandomForestRegressor(n_estimators=200, min_samples_split=20, random_state=69)
model_5 = RandomForestRegressor(n_estimators=100, max_depth=7, random_state=69)
models = [model_1, model_2, model_3, model_4, model_5]

mae1 = score_model(model_1, X_t=X_train, X_v=X_valid, y_t=y_train, y_v=y_valid)
print('model 1 MAE is :')
print(mae1)