For true values y=[2,4,6,8] and linear-regression predictions y^=[3,3,7,7] (fitted with p=1 feature), what are R2 and adjusted R2, how can test-set R2 become negative, and why does adding a pure-noise feature never reduce training R2 whereas adjusted R2 penalises it?

ML systems and evaluation, Regression metrics
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you understand the variance-explained formula for R2, its out-of-sample behaviour, and the degrees-of-freedom penalty in adjusted R2.

Key idea

R2=1−SSresSStot compares a model’s squared error against predicting the sample mean yˉ; adding a feature never increases training SSres, while Radj2=1−(1−R2)(n−1)n−p−1 (for n examples and p features excluding the intercept) divides by residual degrees of freedom n−p−1 so a new feature improves Radj2 only if its error drop outweighs losing a degree of freedom.

Steps

  1. Compute yˉ=5, total sum of squares SStot=(2−5)2+(4−5)2+(6−5)2+(8−5)2=20, and residual sum of squares SSres=(2−3)2+(4−3)2+(6−7)2+(8−7)2=4.
  2. Compute R2=1−420=0.80, and adjusted R2 for n=4,p=1: Radj2=1−(1−0.80)(4−1)4−1−1=1−0.602=0.70.
  3. Explain negative R2: on a test set (or for a model without an intercept, or a poor non-linear model), predictions can be worse than simply predicting yˉtest, making SSres>SStot and R2<0.
  4. Explain adding noise features: OLS can always set the new weight to 0, so training SSres can only stay flat or drop (meaning training R2 is monotonically non-decreasing in p), whereas Radj2 increases only if the drop in SSres outweighs the loss of one degree of freedom in n−p−1.

Common mistakes

How long your answer should be

Three lines of arithmetic and 4–5 sentences; 4 minutes.

Last checked on 4 December 2026.

Read this

Previous in ML systems and evaluation: A calibrated fraud model outputs p=P(fraud∣x). Missing a fraud costs ₹10,000 and flagging a legitimate transaction costs ₹1,000 in review effort. Derive the cost-minimising threshold. What would you do if the model were not calibrated?
Next in ML systems and evaluation: A student standardises features and applies PCA on the full dataset before running 5-fold cross-validation, obtaining 92% accuracy, whereas fitting both inside each fold yields 81%. Why does the first setup leak information, how does a pipeline fix it, and why is supervised feature selection before CV even more damaging?