KatInterview

Designing a Sample-Wise Double Descent Experiment in Linear Regression

Machine LearningModel answer
HardModel answerMachine Learningdouble descentgeneralizationlinear regression

Last updated

Design and analyze a synthetic linear regression experiment that demonstrates how test error spikes near the interpolation threshold as sample size varies.

Background

Classical statistical learning theory predicts that test error should decrease monotonically as you collect more training data. Modern high-dimensional practice tells a different story: there is a critical sample size where test error spikes dramatically before dropping again as you add even more data. This non-monotone behavior — where the risk curve dips, rises sharply, then dips again — is called double descent, and it appears even in the simplest models.

Your task is to propose a rigorous, reproducible synthetic experiment that isolates and demonstrates sample-wise double descent in linear regression, and to explain the mathematical mechanisms behind it.


What to Design

You are fixing the feature dimension d and varying the number of training samples n. Describe each component of the experiment clearly:

1. Data Generating Process Specify the distribution of input features, the ground-truth weight vector, and how targets are produced: y = xᵀw* + ε with additive Gaussian noise σ². Choose concrete values for all hyperparameters and justify them.

2. Estimator Identify the estimator to use in each regime:

  • When n > d (more samples than features): which standard estimator applies, and under what conditions is it defined?
  • When n < d (fewer samples than features): the system is underdetermined; what criterion selects a unique solution, and what is the closed-form expression?

Describe a single unified implementation that handles both regimes automatically.

3. Evaluation Protocol Explain how to measure test risk without relying on a held-out test set (hint: use the problem's structure). Specify the sweep range for n, the sampling density around the critical region n ≈ d, the number of independent trials per n, and why the mean may be misleading near n = d.


Analysis Questions

Address each of the following in your answer:

A. Why does the error peak at n ≈ d? Use the singular value decomposition of the design matrix X to explain what happens to the smallest singular values as n approaches d. Connect this to how noise enters the estimator.

B. Bias and variance across the threshold Provide the exact expressions for bias and variance in both the underparameterized (n > d) and overparameterized (n < d) regimes. Which term drives the peak — bias, variance, or both? What happens to each as n crosses d?

C. What if label noise is zero? Set σ² = 0 and describe the resulting risk curve. Does the peak survive? Give a precise explanation, and describe a realistic scenario where a peak can re-emerge even without additive noise.


What a Strong Answer Looks Like

A strong answer provides: concrete parameter choices with justification, a unified Python implementation, closed-form theoretical risk curves that the simulation can be checked against, precise mathematical statements about singular value behavior, a clean separation of bias and variance, and correct handling of the degenerate points n ∈ {d−1, d, d+1}. Discuss at least one follow-up extension (e.g., effect of ridge regularization or anisotropic features).

Hints

Hint 1

The peak's height is controlled by the smallest nonzero singular value of X. Random matrix theory tells you exactly how that value behaves as n approaches d — write it down explicitly before trying to explain the risk formula.

Hint 2

For isotropic Gaussian features, test risk has a closed form: E[(xᵀŵ − y)²] = ||ŵ − w*||² + σ². You do not need a test set at all. This also means you can overlay a theoretical curve on your simulation as a sanity check.

Hint 3

Bias and variance behave very differently near the threshold: one is smooth and linear in n, the other diverges. Figuring out which is which will tell you exactly why σ² = 0 eliminates the peak — and what has to be true about a noise-free problem for the peak to return.