Complete the code to import the class used for polynomial features.
from sklearn.preprocessing import [1]
The PolynomialFeatures class is used to generate polynomial and interaction features from the original features.
Complete the code to create polynomial features of degree 3.
poly = PolynomialFeatures(degree=[1])Setting degree=3 creates polynomial features up to cubic terms.
Fix the error in transforming features to polynomial features.
X_poly = poly.[1](X)fit_transform fits the transformer and applies the transformation in one step, which is needed here.
Fill both blanks to train a linear regression model on polynomial features.
model = LinearRegression() model.[1](X_poly, y) predictions = model.[2](X_poly)
First, fit trains the model on data. Then, predict generates predictions from the trained model.
Fill all three blanks to create polynomial features, train the model, and compute the R² score.
poly = PolynomialFeatures(degree=[1]) X_poly = poly.[2](X) model = LinearRegression() model.fit(X_poly, y) score = model.[3](X_poly, y)
Degree 3 creates cubic features. fit_transform prepares the features. score computes the R² metric to evaluate the model.
