Issue
I would like to write a function that allows me to calculate the root mean square error obtained by 5-sample cross-validation using the cross_val_score function of sklearn.model_selection.
(Knowing that the scoring argument of the cross_val_score()function allows to choose the metric we want to use.)
I found this method, but it does not correspond to the question :
def rmse(predictions, targets):
return np.sqrt(((predictions - targets)**2).mean())
Thank you very much, Merci beaucoup :)
Solution
You can simply set scoring='mean_squared_error'
in sklearn.model_selection.cross_val_score
. Check out the documentation for the validator and the metric.
In other words:
cv = cross_val_score(estimator=my_estimator, X, y, cv=5, scoring='mean_squared_error')
Answered By - Arturo Sbr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.