custom scoring function gridsearchcv
# create custom loss function
from sklearn.metrics import make_scorer
# custom loss function
def rmse_loss(y_true, y_pred):
return np.sqrt(np.mean(np.square(y_pred - y_true)))
rmse = make_scorer(rmse_loss, greater_is_better=False)
# training randomized search cv
model_rndm = RandomizedSearchCV(RandomForestRegressor(),
param_distributions=random_grid,
n_iter=200, scoring=rmse, cv=3, n_jobs=-1)
↑
# our custom loss function