Regularization is a form of regression. In regularization, the estimated coefficients in regression equations are constrained to zero. This is one of the major techniques used to avoid overfitting.
Regularization is a method that can be utilized for any given training set. It reduces errors by fitting the function appropriate to the training set. As a result, this method avoids overfitting.
The commonly used regularization techniques are:
General equation looks like:
y = β0 + β1x1 + β2x2 + ··· βkxk + λ(slope)²
Loss function:
y = β0 + β1x1 + β2x2 + ··· βkxk + λ|slope|
Loss function:
Output function:
We define the loss function in logistic regression as:
L(y_hat,y) = y log y_hat + (1 - y)log(1 - y_hat)
Loss function with no regularization:
L = y log (wx + b) + (1 - y)log(1 - (wx + b))
Let’s say the data overfits the above function.
Loss function with L1 regularization:
L = y log (wx + b) + (1 - y)log(1 - (wx + b)) + lambda*||w||
Loss function with L2 regularization:
L = y log (wx + b) + (1 - y)log(1 - (wx + b)) + lambda*||w|| ^ 2
Note that lambda is a hyperparameter known as the regularization constant – it is greater than zero.
Free Resources