Skip to content

What is Regularization?

Regularization is a set of techniques in machine learning that reduce overfitting by adding a penalty term to the model's loss function, discouraging overly complex or large parameter values.

Overfitting happens when a model learns noise and patterns specific to the training data instead of the underlying trend, leading to poor performance on new data. Regularization counters this by constraining model complexity during training.

It works by modifying the objective function that the optimizer minimizes. Common approaches include L1 regularization (Lasso), which can drive some weights to exactly zero, and L2 regularization (Ridge), which shrinks all weights toward zero without eliminating them.

The strength of the penalty is controlled by a hyperparameter (often called lambda or alpha). Larger values increase the constraint, trading off training accuracy for better generalization.

Example

In linear regression predicting house prices, adding L2 regularization penalizes large coefficients for features like square footage, resulting in a smoother model that performs better on unseen homes rather than memorizing the training set.

Why it matters

Modern AI models with millions of parameters easily overfit limited data; regularization is essential for building reliable, generalizable systems used in production across healthcare, finance, and recommendation engines.

Frequently asked questions

L1 can set some weights to zero (feature selection), while L2 shrinks all weights but rarely to zero, making L2 better for correlated features.