April 2019
Intermediate to advanced
426 pages
11h 13m
English
The ridge regression, or L2 regularization, addresses some of the problems of OLS regression by penalizing the sum of squares of the model coefficients. The cost function for the ridge regression can be written as follows:

Here, the α parameter is expected to be a positive value that controls the amount of shrinkage. Larger values of alpha give greater shrinkage, making the coefficients more robust to collinearity.
The Ridge class of the sklearn.linear_model module implements ridge regression. To implement this model, create a class named RidgeRegressionModel that extends the LinearRegressionModel class, and run the following ...