Complete the code to create a simple linear regression model using scikit-learn.
from sklearn.linear_model import LinearRegression model = LinearRegression([1])
The fit_intercept=True parameter tells the model to calculate the intercept (bias) term. This is essential for linear regression.
Complete the code to train the linear regression model on data X and y.
model.[1](X, y)The fit method trains the model by finding the best line that fits the data.
Fix the error in the code to make predictions using the trained model.
predictions = model.[1](X_test)The predict method is used to get the model's output on new data.
Fill both blanks to calculate the mean squared error between true and predicted values.
from sklearn.metrics import [1] mse = [2](y_true, y_pred)
The mean_squared_error function calculates the average squared difference between true and predicted values, a common error metric for regression.
Fill all three blanks to create a dictionary of coefficients for each feature with their names.
coef_dict = {{ [1]: [2] for [3], coef in zip(feature_names, model.coef_)}This dictionary comprehension pairs each feature name with its coefficient from the model.
