liveBook · Manning

Regularization

As explained in Ensemble Methods for Machine Learning

A regularization function is a function that assigns a penalty to model parameters or complexity as part of a regularized objective.

Regularization adds a preference for simpler models to training. Instead of minimizing training error alone, a regularized objective combines a loss term, which measures fit to observed data, with a penalty term, which measures model complexity. The balance matters: minimizing loss alone can produce a model that fits training data extremely well but fails to generalize; emphasizing the penalty too strongly can make the model too simple to capture the signal. section 6.2.2 section 7.1.1

The regularization parameter sets that balance. With an α-style objective, larger α puts more weight on simplicity, raising training error and risking underfitting; smaller α favors training fit and can permit overfitting. Some estimators express the same tradeoff in the opposite direction: in support vector regression, small C emphasizes regularization, while large C emphasizes fit. section 6.2.2 section 1.3.2

Regularization can constrain complexity in several ways:

  • Restrict tree structure, such as maximum depth or node count, so trees cannot grow arbitrarily complex. section 6.2.2
  • Apply an L2 penalty directly to model parameters, shrinking weights to improve robustness, particularly with highly correlated features. section 7.1.1
  • Apply an L1 penalty, which shrinks weights more strongly and encourages sparse models through implicit feature selection. section 7.1.1
  • Combine L1 and L2 penalties with Elastic Net to balance sparsity and robustness. section 7.1.1
  • Penalize the number of leaf nodes in boosted trees, encouraging shallower, weaker trees. section 6.3.1

Tuning an SVM without trusting training fit

An RBF support vector regressor makes the tradeoff visible. At low C, the learned curve is flatter and less complex, often underfitting. Raising C lets the curve follow the training data more closely, but sufficiently high values can overfit. Compare cross-validated training and test R² across candidate C values rather than selecting the setting with the best training score. section 1.3.2 section 1.3.2

Regularized objectives can also change optimization behavior. Adding a smoothing term can make a loss more convex, or bowl-like, with a better-defined minimum; this added structure can stabilize and accelerate learning. The benefit is not free: regularization strengths such as α and the XGBoost leaf penalty γ are user-selected parameters, commonly chosen with cross-validation, adding model-development effort. section 6.2.2 section 6.3.1

Table 7.1 Four popular linear regression methods that all use the squared-loss function but use different regularization approaches to contribute to model robustness and sparsity (view table figure)

Model

Loss function

Regularization

Comment

OLS regression

Squared loss(y - f(x))2

None

Classical linear regression; becomes unstable with highly correlated features

Ridge regression

Squared loss(y - f(x))2

L2 penalty

1/2(w12+ ⋅⋅⋅ + wd2)

Shrinks the weights to control model complexity, and encourages robustness to highly correlated features

LASSO

Squared loss(y - f(x))2

L1 penalty

|w1| + ⋅⋅⋅ + |wd|

Shrinks the weights even more, encourages sparse models, performs implicit feature selection

Elastic net

Squared loss(y - f(x))2

ρL1 + (1 - ρ)L2

0 ≤ ρ ≤ 1

Weighted combination of both regularizers to balance between sparsity and robustness

Compare OLS, Ridge, LASSO, and Elastic Net: all use squared loss, but their penalties lead to different robustness and sparsity behavior. section 7.1.1

How Ensemble Methods for Machine Learning covers it

How deep it goes
Defines regularized objectives and parameters, then applies L1, L2, structural, SVM, and boosted-tree penalties without formal proofs.
Examples
Uses RBF SVR on Friedman-1 data and noisy synthetic linear regression comparing OLS, Ridge, LASSO, and Elastic Net.
What it assumes
Assumes familiarity with regression, loss functions, training error, and cross-validation while introducing regularized objectives intuitively.
What you can do after
Apply it via scikit-learn models and cross-validation to select a fit-complexity tradeoff.
How it connects
Connects loss functions, cross-validation, underfitting, overfitting, support vector regression, decision trees, Ridge, LASSO, Elastic Net, and XGBoost.

Also explained in

Compare how 13 books explain regularization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.