I came across explained variance score and $R^2$ score in scikit learn docs.

Docs defines exaplained variance score as:

$\text{explained variance} (y,\hat{y})=1-\frac{Var\{y-\bar{y}\}}{Var\{y\}}$

which I feel equates to $$1-\frac{\sum(y-\hat{y}-\overline{(y-\hat{y})})^2}{\sum(y-\bar{y})^2}\quad\quad\quad\quad...(I)$$

Docs then define $R^2$ score as follows:

$$R^2(y,\hat{y})=1-\frac{\sum(y-\hat{y})^2}{\sum(y-\bar{y})^2} \quad\quad\quad\quad...(II)$$

The difference between equation $(I)$ and $(II)$ is that equation $(I)$ has $"-\overline{(y-\hat{y})}"$ in the numerator, while equation $(II)$ does not. I have learnt from the various sources what different values of $R^2$ indicate:

  • $R^2<0→$ horizontal line explains the data better than the model, in other words, the chosen model does not follow the trend of the data
  • $R^2=0→$ horizontal line explains the data as well as the model, i.e. model has no explanatory value
  • $R^2>0→$ model explains the data better than the horizontal line
  • $R^2=1→$ means the model / regression line explains 100% of the variation in the response variable. This will be the case when all the data points lie precisely on the regression line

Q1. What to make sense of different values of "explained variance" and why?
Q2. Also, the doc points to this wiki page which does not give formula in equation $(I)$. Why so?
Q3. How the two quantities are related intuitively?

  • $\begingroup$ See stackoverflow.com/questions/24378176/… $\endgroup$
    – Sergio
    Jul 16, 2021 at 22:11
  • $\begingroup$ Put a lot time on that stackoverflow question. Accepted answer was quite convoluted in code. Also found second highest rated answer quite confusing. This is what I made sense from it and after some thinking, but need confirmation: Q3. "Explained variance" is unbiased version of $R^2$ obtained by subtracting $\overline{(y-\hat{y})^2}$ from the numerator of $R^2$. Q1. Since "explained variance" is just an unbiased version of $R^2$, its different values carry same meaning as explained in question for $R^2$. Q2. Not sure why. They might just have missed it. $\endgroup$
    – Rnj
    Jul 19, 2021 at 11:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.