I was reading about regression metrics in the python scikit-learn manual and even though each one of them has its own formula, I cannot tell intuitively what is the difference between $R^2$ and variance score and therefore when to use one or another to evaluate my models.
2 Answers
$R^2 = 1- \frac{SSE}{TSS}$
$\text{explained variance score} = 1 - \mathrm{Var}[\hat{y} - y]\, /\, \mathrm{Var}[y]$, where the $\mathrm{Var}$ is biased variance, i.e. $\mathrm{Var}[\hat{y} - y] = \frac{1}{n}\sum(error - mean(error))^2$. Compared with $R^2$, the only difference is from the mean(error). if mean(error)=0, then $R^2$ = explained variance score
Also note that in adjusted-$R^2$, unbiased variance estimation is used.
-
2
-
-
-
$\begingroup$ @Hack-R For adjusted R2 see this: stackoverflow.com/questions/51023806/… and stackoverflow.com/questions/49381661/… $\endgroup$ Feb 25, 2021 at 17:27
Dean's answer is right.
Only I think there is a minor typo here: $Var[\hat{y}-y]=sum(error^2-mean(error))/n$.
I guess it should be $Var[\hat{y}-y]=sum(error-mean(error))^2/n$.
My reference is the source code of sklearn here:https://github.com/scikit-learn/scikit-learn/blob/bf24c7e3d/sklearn/metrics/_regression.py#L396