Ridge regularization
In the last exercise you practiced performing lasso regularization. If you're asked about regularization techniques in a machine learning interview, know what differentiates the 2 norms. Lasso uses the L1 norm corresponding to the penalty parameter and the absolute value of the coefficients. Ridge regression performs L2 regularization, also known as L2-norm, which adds a penalty term to ordinary least squares using the penalty parameter and the sum of the squared coefficients.
For this exercise, you'll practice regularization with Ridge on the diabetes
DataFrame. The feature matrix and target array are saved to your workspace as X
and y
, respectively.
Already imported for you are mean_squared_error
from sklearn.metrics
and train_test_split
from sklearn.model_selection
.
This exercise is part of the course
Practicing Machine Learning Interview Questions in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import modules
from sklearn.____ import ____
from sklearn.____ import ____