Complete the code to import the Ridge regression model from scikit-learn.
from sklearn.linear_model import [1]
The Ridge regression model is imported from sklearn.linear_model using Ridge.
Complete the code to create a Lasso regression model with alpha set to 0.1.
model = Lasso(alpha=[1])The alpha parameter controls the strength of regularization. Setting it to 0.1 applies moderate L1 regularization.
Fix the error in the code to fit a Ridge model to data X and y.
model = Ridge(alpha=1.0) model.[1](X, y)
The fit method trains the model on the data. Using predict or others here causes errors.
Fill both blanks to create a dictionary of coefficients from a trained Lasso model for features in feature_names.
coef_dict = {feature: model.[1][i] for i, feature in enumerate([2])}intercept_ instead of coef_.predict which is a method, not an attribute.The coefficients are stored in coef_ after training. We map them to feature names to understand their impact.
Fill all three blanks to compute the mean squared error (MSE) between true values y_true and predicted values y_pred.
from sklearn.metrics import [1] y_pred = model.predict(X_test) mse = [2](y_true, [3])
The function mean_squared_error is imported and used to calculate MSE between true and predicted values.
