0
0
ML Pythonprogramming~10 mins

Regularization (Ridge, Lasso) in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Ridge regression model from scikit-learn.

ML Python
from sklearn.linear_model import [1]
Drag options to blanks, or click blank then click option'
ALinearRegression
BLasso
CLogisticRegression
DRidge
Attempts:
3 left
2fill in blank
medium

Complete the code to create a Lasso regression model with alpha set to 0.1.

ML Python
model = Lasso(alpha=[1])
Drag options to blanks, or click blank then click option'
A0.1
B0
C10
D1.0
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to fit a Ridge model to data X and y.

ML Python
model = Ridge(alpha=1.0)
model.[1](X, y)
Drag options to blanks, or click blank then click option'
Apredict
Btransform
Cfit
Dscore
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create a dictionary of coefficients from a trained Lasso model for features in feature_names.

ML Python
coef_dict = {feature: model.[1][i] for i, feature in enumerate([2])}
Drag options to blanks, or click blank then click option'
Acoef_
Bfeature_names
Cintercept_
Dpredict
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to compute the mean squared error (MSE) between true values y_true and predicted values y_pred.

ML Python
from sklearn.metrics import [1]
y_pred = model.predict(X_test)
mse = [2](y_true, [3])
Drag options to blanks, or click blank then click option'
Amean_squared_error
By_pred
Daccuracy_score
Attempts:
3 left