Calculate the explained variance score for a regression model's predictions.
The explained variance score measures how much of the variance in the actual values is captured by the model, ignoring any constant bias: EV = 1 − Var(y − ŷ) / Var(y). It's closely related to R², but R² also penalizes systematic bias (a constant offset between predictions and actuals), while explained variance only looks at how well the model captures the spread of the data. A score of 1.0 means the model perfectly explains all variability, and 0.0 means it explains none.
EV = 1 - Var(y - y_hat) / Var(y)
R² penalizes both variance mismatch and any systematic bias (mean offset) between predictions and actuals, while explained variance only measures variance mismatch — if a model's predictions are shifted by a constant amount but track the actual values' ups and downs perfectly, explained variance would still be close to 1 even though R² would be lower.
Yes — like R², if the residual variance is larger than the variance of the actual values themselves, explained variance becomes negative, indicating the model performs worse than a naive constant prediction in terms of capturing variability.
Use explained variance when you specifically care about whether the model captures the pattern/spread of the data and are less concerned about a constant systematic bias, which some post-processing or calibration step could correct separately.