PolynomialFeatures(degree=4)
Great question — let’s go step by step.
The code builds a Pipeline with:
-
PolynomialFeatures(degree=4)
So the pipeline automatically handles feature transformation + regression when you call .fit().
Missing Part Before Prediction:
model.fit(X_train, y_train)
Why Not the Other Options?
-
model.train(...)→ Scikit-learn estimators use.fit(), not.train(). -
model.fit(PolynomialFeatures(...).fit_transform(X_train), y_train)→ Unnecessary, since the pipeline already applies polynomial transformation inside. -
model.fit_transform(X_train, y_train)→.fit_transform()is used for transformers (likeStandardScaler), not for the whole pipeline when training.
✅ Correct Answer:
model.fit(X_train, y_train)
Do you want me to also walk through how the pipeline works internally (i.e., how fit and predict automatically chain PolynomialFeatures + LinearRegression)?
Comments
Post a Comment