Optimizing the ridge regression parameter
Once you start using ridge regression to make predictions or learn about relationships in the system you're modeling, you'll start thinking about the choice of alpha.
For example, using ordinary least squares (OLS) regression might show a relationship between two variables; however, when regularized by an alpha, the relationship is no longer significant. This can be a matter of whether a decision needs to be taken.
Getting ready
Through cross-validation, we will tune the alpha parameter of ridge regression. If you remember, in ridge regression, the gamma parameter is typically represented as alpha in scikit-learn when calling RidgeRegression
; so, the question that arises is what is the best alpha? Create a regression dataset, and then let's get started:
from sklearn.datasets import make_regression reg_data, reg_target = make_regression(n_samples=100, n_features=2, effective_rank=1, noise=10)
How to do it...
In the linear_models
module, there is an object...