Regularization in Machine Learning

Prerequsites: Gradient Descent

Overfitting is a phenomenon that occurs when a Machine Learning model is constraint to training set and not able to perform well on unseen data.

Regularisation is a technique used to reduce the errors by fitting the function appropriately on the given training set and avoid overfitting.
The commonly used regularisation techniques are :

  1. L1 regularisation
  2. L2 regularisation
  3. Dropout regularisation

This article focus on L1 and L2 regularisation.



A regression model which uses L1 Regularisation technique is called LASSO(Least Absolute Shrinkage and Selection Operator) regression.
A regression model that uses L2 regularisation technique is called Ridge regression.
Lasso Regression adds “absolute value of magnitude” of coefficient as penalty term to the loss function(L).

Ridge regression adds “squared magnitude” of coefficient as penalty term to the loss function(L).

NOTE that during Regularisation the output function(y_hat) does not change. The change is only in the loss function.

The output function:

The loss function before regularisation:



The loss function after regularisation:

We define Loss function in Logistic Regression as :

                    L(y_hat,y) = y log y_hat + (1 - y)log(1 - y_hat)

 

Loss function with no regularisation :

                L = y log (wx + b) + (1 - y)log(1 - (wx + b))   

Lets say the data overfits the above function.

Loss function with L1 regularisation :

                      L = y log (wx + b) + (1 - y)log(1 - (wx + b)) + lambda*||w||1    

Loss function with L2 regularisation :

                      L = y log (wx + b) + (1 - y)log(1 - (wx + b)) + lambda*||w||22    

lambda is a Hyperparameter Known as regularisation constant and it is greater than zero.

                           lambda > 0
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : nipul00khandelwal

Article Tags :
Practice Tags :


3


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.