Python differences between the methods of the score regression model and the r2 score function
When building the model, I wanted to compare the values of r2_score () - the coefficient of determination, which I did, but when reading the documentation for the functions of the models, I came across this line.
Score(self, X, y[, sample_weight]) Returns the coefficient of determination R^2 of the prediction.
Does the score() method also return the coefficient of determination?
1 answers
I don't remember the method r2_score()
.
R2_score() is a regressor-independent metric function, and regression_class.score()
- this is a class method that internally calls the metric r2_score()
Notes
The R2 score used when calling score on a regressor will use
multioutput='uniform_average'
from version 0.23 to keep consistent with metrics.r2_score. This will influence the score method of all the multioutput regressors (except formultioutput.MultiOutputRegressor
). To specify the default value manually and avoid the warning, please either callmetrics.r2_score
directly or make a custom scorer with metrics.make_scorer (the built-in scorer'r2'
usesmultioutput='uniform_average'
).