Complete the code to create a polynomial feature transformer.
from sklearn.preprocessing import [1] poly = PolynomialFeatures(degree=2)
The PolynomialFeatures class generates polynomial and interaction features, which help regression models capture non-linear relationships.
Complete the code to fit a linear regression model on polynomial features.
from sklearn.linear_model import LinearRegression model = LinearRegression() X_poly = poly.fit_transform(X) model.[1](X_poly, y)
predict instead of fit to train the model.The fit method trains the model on the transformed polynomial features and target values.
Fix the error in the code to predict using the polynomial regression model.
X_new_poly = poly.transform(X_new)
predictions = model.[1](X_new_poly)fit or transform instead of predict for predictions.The predict method generates predictions from the trained model using new polynomial features.
Fill both blanks to create a dictionary of feature names and their coefficients from the model.
feature_names = poly.get_feature_names_out(input_features) coef_dict = [1](zip(feature_names, model.[2]_))
coef without underscore or wrong function to create dictionary.The dict function creates a dictionary from zipped feature names and coefficients stored in coef_.
Fill both blanks to compute the mean squared error of the polynomial regression model predictions.
from sklearn.metrics import [1] y_pred = model.predict(X_poly) mse = [2](y, y_pred) print('Mean Squared Error:', mse)
The mean_squared_error function calculates the average squared difference between actual and predicted values, a common regression metric.