Why must the regularization parameter lambda be selected on validation data rather than training data?

Last updated 3 November 2026

Training error almost always falls as λ falls, because a less constrained model can fit the training data better. Selecting on training data would therefore always pick λ ≈ 0, which is no regularization at all. λ exists to optimize generalization, so it must be chosen using data the fit did not see.

  • Training error is a biased estimate:

    • It is optimistic, and the optimism grows with model flexibility (effective degrees of freedom).

    • Lowering λ raises flexibility, so training error rewards overfitting.

  • Validation error estimates generalization:

    • It traces the U-shaped bias–variance curve. Large λ underfits, small λ overfits, and the minimum sits in between.

    • K-fold cross-validation reduces the noise of a single split.

  • Keep the test set separate:

    • Tuning λ on validation data makes validation error optimistic too, because you picked the minimum.

    • Report performance on an untouched test set, or use nested CV.

  • Avoid leakage:

    • Fit preprocessing such as scaling or feature selection inside each training fold.

    • Scaling matters especially here, because penalties depend on feature scale.

  • Alternatives: information criteria (AIC, BIC) or generalized CV. These adjust training error for complexity analytically, but they still don't simply minimize raw training error.

  • https://www.youtube.com/watch?v=_h_tTtw5y84
  • https://medium.com/@coder_cat/nail-your-data-science-interview-day-4-regularization-techniques-7dae7cc71279
  • https://medium.com/data-and-beyond/regularization-and-model-selection-understanding-cs229-generalization-and-regularization-ba537cd9ccf7
All Regularization interview questions