Complete the code to import the linear regression model from scikit-learn.
from sklearn.linear_model import [1]
The LinearRegression class is used for multiple linear regression in scikit-learn.
Complete the code to create a linear regression model instance.
model = [1]()We create an instance of LinearRegression to train a multiple linear regression model.
Fix the error in the code to train the model with features X and target y.
model.fit([1], y)The fit method requires the features as the first argument and the target as the second.
Fill both blanks to predict target values and calculate the mean squared error.
predictions = model.[1](X_test) mse = mean_squared_error(y_test, [2])
fit instead of predict for predictions.Use predict to get predictions from the model, then pass those predictions to mean_squared_error to calculate error.
Fill all three blanks to create a dictionary of coefficients, intercept, and R² score.
results = {
'coefficients': model.[1],
'intercept': model.[2],
'r2_score': model.[3](X_test, y_test)
}fit with score.The model's coefficients are in coef_, intercept in intercept_, and score computes the R² on test data.
