Ridge regression is a classification algorithm that works in part as it doesn’t require unbiased estimators. Ridge regression minimizes the residual sum of squares of predictors in a given model. Ridge regression includes a shrinks the estimate of the coefficients towards zero.
Ridge regression is a regularized regression algorithm that performs L2 regularization that adds an L2 penalty, which equals the square of the magnitude of coefficients. All coefficients are shrunk by the same factor i.e none are eliminated. L2 regularization will not result in sparse models. Ridge regression adds bias to make the estimates reliable approximations to true population values. Ridge regression proceeds by adding a small value k to the diagonal elements of the correlation matrix i.e ridge regression got its name since the diagonal of ones in the correlation matrix are thought to be a ridge.
Here, k is a positive quantity less than 1(usually less than 0.3). The amount of bias in estimator is given by:
The covariance matrix is given by:
There exists a value of k for which the Mean Squared Error(MSE i.e variance plus the bias squared) of the ridge estimator is less than least squares estimator. The appropriate value of k depends on the true regression coefficients(that are being estimated)and the optimality of the ridge solution.
- When lambda = 0, ridge regression equals least squares regression.
- When lambda = infinity, all coefficients shrunk to zero.
Also, the ideal penalty is in between 0 and infinity. Let’s implement Ridge regression in R programming.
Implementation in R
Big Mart dataset consists of 1559 products across 10 stores in different cities. Certain attributes of each product and store have been defined. It consists of 12 features i.e Item_Identifier( is a unique product ID assigned to every distinct item), Item_Weight(includes the weight of the product), Item_Fat_Content(describes whether the product is low fat or not), Item_Visibility(mentions the percentage of the total display area of all products in a store allocated to the particular product), Item_Type(describes the food category to which the item belongs), Item_MRP(Maximum Retail Price (list price) of the product), Outlet_Identifier(unique store ID assigned. It consists of an alphanumeric string of length 6), Outlet_Establishment_Year(mentions the year in which store was established), Outlet_Size(tells the size of the store in terms of ground area covered), Outlet_Location_Type(tells about the size of the city in which the store is located), Outlet_Type(tells whether the outlet is just a grocery store or some sort of supermarket) and Item_Outlet_Sales( sales of the product in the particular store).
Performing Ridge Regression on Dataset
Using Ridge regression algorithm on the dataset which includes 12 features with 1559 products across 10 stores in different cities.
- Model Ridge_model:
The Ridge regression model uses the alpha value as 0 and lambda value as 0.1. RMSE was used to select the optimal model using the smallest value.
- Mean validation score:
The mean validation score of the model is 1133.668.
The regularization parameter increases, RMSE remains constant.
So, Ridge regression applications are used in many sectors of industry and with full capacity.My Personal Notes arrow_drop_up