First of all, let's import PolynomialFeatures:
from sklearn.preprocessing import PolynomialFeatures
Then let's create an object to make a list of all the possible feature combinations/powers:
poly = PolynomialFeatures(n)
where we have already defined n as whatever max degree we want to try till.
Let's say we want to get the polynomial features for our current training data set. Assuming that we have performed the standard train-test split, and set train_x as the set of training inputs:
train_x_poly = poly.fit_transform (train_x)
That's all the training data, with polynomial/powered features, so now we can just feed that to the standard linear regression. Still, we'll do Polynomial Regression in a following Notebook.