R2 Score

July 30, 2023

By Admin


R2 Score

The R2 score(R- Squared), also known as the coefficient of determination, is a statistical measure that represents the proportion of the variance in the dependent variable (target) that is predictable from the independent variable(s) (features) in a regression model. It indicates how well the regression model fits the observed data points.

The formula for R2 Score is given by

R2Score

Where,
Sum of Squared Residuals : The sum of the squared differences between the actual dependent variable ( Y ) and the predicted value ( Ypred ) by regression model.

Total Sum of Squares: The sum of the squared differences between the actual dependent variable ( Y ) and the mean dependent variable ( Ymean )

In mathematical terms, this can be expressed as:

R2Score

The R2 score can range from 0 to 1. A value of 1 indicates that the regression model perfectly fits the data, while a value of 0 suggests that the model does not explain any variance in the data.

However one limitation of R2 score is that it can increase even if additional independent variables (features) are added to the model, regardless of whether they are relevant or not. This can lead to overfitting. To address this, the Adjusted R2 score is used, which penalizes the addition of irrelevant variables.

The formula for Adjusted R2 score is given by

R2Score

Where,
● n is the number of samples( datapoints )
● p is the number of independent variables (features) in the model.

The Adjusted R2 score will always be lower or equal to the R2 score It penalizes the model for including irrelevant variables and provides a more realistic measure of the goodness of fit.

In summary, R2 measures the proportion of variance in the dependent variable that is explained by the regression model, while Adjusted R2 adjusts for the number of independent variables to provide a more balanced evaluation of model performance. Both scores are essential tools for evaluating the effectiveness of regression models.

Interview Questions :

1. What is R2 Score?

2. What is the formula for R2 Score?

3. What are the limitations of R2 Score?