![]() |
VOOZH | about |
The Coefficient of determination, also called R² score, is used to evaluate the performance of a linear regression model. It is the amount of the variation in the output dependent attribute that is predictable from the input independent variable(s). It is used to check how well-observed results are reproduced by the model, depending on the ratio of the total deviation of results described by the model.
Mathematical Formula:
Where,
Assume R2 = 0.68. It can be inferred that 68% of the changeability of the dependent output attribute can be explained by the model, while the remaining 32 % of the variability is still unaccounted for. R2 indicates the proportion of data points that lie within the line created by the regression equation. A higher value of R2 is desirable as it indicates better results.
We can import r2_score from sklearn.metrics in Python to compute R2 score.
Output:
r2 score for perfect model is 1.0
Output:
r2 score for a model which predicts mean value always is 0.0
Output:
r2 score for a worse model is -2.0