text_plain_output_1.png
from catboost import CatBoostRegressor

from lightgbm import LGBMRegressor

from sklearn.ensemble import GradientBoostingRegressor

from sklearn.ensemble import RandomForestRegressor

from sklearn.metrics import mean_squared_error

from sklearn.neighbors import KNeighborsRegressor

from sklearn.neural_network import MLPRegressor

from xgboost import XGBRegressor

import matplotlib.pyplot as plt

import numpy as np # linear algebra

def check_rmse(model, x_val, y_val):
    pred = model.predict(x_val)
    return np.sqrt(mean_squared_error(y_val, pred))

knn_reg = KNeighborsRegressor(n_jobs=-1)
mlp_reg = MLPRegressor()
rf_reg = RandomForestRegressor(n_jobs=-1)
gb_reg = GradientBoostingRegressor()
xgb_reg = XGBRegressor(n_jobs=-1)
lgbm_reg = LGBMRegressor(n_jobs=-1)
cat_reg = CatBoostRegressor()

models = [knn_reg, mlp_reg, rf_reg, gb_reg, xgb_reg, lgbm_reg, cat_reg]
models_name = ['knn_reg', 'mlp_reg', 'rf_reg', 'gb_reg', 'xgb_reg', 'lgbm_reg', 'cat_reg']

rmse_error = []
for i, model in enumerate(models):
    model.fit(X_train, Y_train)
    rmse = check_rmse(model, X_val, Y_val)
    rmse_error.append(rmse)

plt.barh(models_name, rmse_error)
plt.ylabel('Models')
plt.xlabel('RMSE')
plt.show()