Regularization is a vital tool in machine learning to prevent overfitting and foster generalization ability. This chapter introduces the concept of regularization and discusses common regularization techniques in more depth.
§15.01: Introduction
Regularisation are methods used to add inductive bias to model usually, some “low complexity” priors (shrinkage & sparsity for eg) to reduce overfitting and get better bias-variance tradeoff. Explicit (L1/L2), Implicit (Early stopping, dropout), Structural Knowledge (group Lasso) are some broad categories (examples) of regularisation.
Increasing the dataset size can be useful but often is not feasible in practice. Another way is reduce model complexity. For example just start with constant model and add one feature at a time in Linear Regression for example. Or we could “optimise less” i.e. early stopping.
Regularised Empirical Risk Minimisation has contradictory goals (maximising the fit and at the same time minimising model complexity). We can add a penalty term which is a function of model complexity to the Empirical Risk Minimisation objective.
§15.02: Ridge Regression
In linear regression if is large enough and is small enough, LR can also overfit. Moreover OLS Estimator requires a full rank design matrix, and for highly correlated features, OLS becomes sensitive to random errors resulting in a large variance.
§15.03: LASSO Regression
Another shrinkage method is the so-called LASSO (least absolute shrinkage and selection operator) which uses the L1 penalty on :
Optimisation becomes much harder because the function is no longer differentiable.
For , LASSO selects atmost features.
§15.04: LASSO vs Ridge Regression
Usually the intercept is not regularised so that the “infinitely” regularised model is the constant model.
Unregularised Linear Regression has rescaling equivariance. If you rescale certain variables then the coefficients change and the risk does not change. For example if a variable was encoded in cm, but we convert it to mm, then the coefficient would be a simple multiple by a 100 for the mm variable. However for the regularised version, the risk for rescaled variables are often different and hence don’t have rescaling equivariance standardize features in regularised linear regression!
Suppose two variables are highly correlated. Then Ridge regression has tends to have “grouping effect” i.e. similar effect on both variables where LASSO arbitrarily decides to select one of them. If , then because the penalty is strictly convex. Since is not strictly convex, sum of coefficents can be arbitrarily allocated across both features i.e.
§15.05: Elastic Net and Regularization for GLMs
It is a “compromise” between L1 and L2 penalties:
Correlated features tend to be selected or zeroed out together and selection more than features possible if .
Unlike pure Ridge, Elasticnet does perform some feature selection and unlike Lasso which sometimes ignores relevant features, Elasticnet keeps them in.
§15.06: Other Types of Regularisation
Although Ridge and Lasso have many desirable properties, they are biased estimators.
Besides , we can also consider Norm: . For , penalty becomes non-convex, and for sparsity is not achieved. Non-convex has the so-called Oracle Property - consitent and asymptotically unbiased estimator and feature selection. However the non-convexity makes the problem quite a bit harder.
The norm simply counts the number of non-zero parameters. Induces sparsity more aggressively than but does not shrink parameters. AIC and BIC are special cases of Norm and the problem is NP-hard.
§15.07: Non-Linear Models and Structural Risk Minimisation
We can summarise regularised risk minimisation using this equation:
hypothesis space of f controls how features influence predictions
loss function L measures how errors are treated
regulariser encodes inductive bias
Structural Risk Minimisation (SRM) assumes that our hypothesis space can be decomposed into a sequence of increasingly complex hypothesis for eg degree of polynomials or size of hidden layer : .
SRM chooses the smallest such that the optimal model from is not significantly outperformed by a model from with . In simple terms, if a model from the higher complexity hypothesis space does not significantly outperform the current complexity level, then choose the optimal model from the current level.
We can also interpret Regularised Risk Minimisation from the lens of SRM by considering each level of as a complexity level.
§15.08: Bayesian Priors
We have previously created an equivalence between MLE and ERM. We can do the same for MAP and RRM. Assume we have a parametrised distribution for our data and a prior distribution over our parameter space, then, as per Bayes rule:
The Maximum Priori Estimator is then given by:
In this formulation we can identify the as our Loss function and and the : our regulariser.
regularisation is equivalent to an MAP estimator with prior and regularisation is equivalent to prior. For the regularisation we can show that larger the variance of our prior, lower the regularisation i.e. the shrinkange is inversely proportional to the variance of our prior.
§15.09: Weight Decay and L2
Consider regularisation:
If we now update using gradient descent, then the gradient is:
Thus we get the following update:
Usually both «. Therefore essentially what is happening is the old parameter is decayed in magnitude before performing an update. Thus this well known technique of weight decay is simply regularisation in disguise. Note that this equivalence only holds for (stochastic) gradient descent and not for Adam, etc.
§15.10: Geometry of L2 Regularisation
§15.11: Geometry of L1 Regularisation
§15.12: Early Stopping
Early stopping is effective and simple to implement. It involves simply stopping optimisation when the validation error stops decreasing.
For a simple linear regression with squared loss and gradient descent optimisation with initial parameters set to 0 has exact correspondence with regularisation. The optimal early stopping iteration small (low regularisation) implies a larger (more complexity of the model).