When data follows a curve rather than a straight line, expand a feature into powers such as x, x², and x³. Linear regression can then combine these columns to represent a polynomial curve. section 4.14
Fitting a curved dataset
A downward-opening parabola does not fit well with ordinary linear regression. PolynomialFeatures(degree=20, include_bias=False) and fit_transform(X) create the expanded dataset; linear regression then fits those 21 columns. Split the data before training, and compare unregularized, Lasso, and Ridge models. section 4.14
Figure 4.8 The dataset. Notice that its shape is a parabola that opens downward, so using linear regression won’t work well. We’ll use polynomial regression to fit this dataset, and we’ll use regularization to tune our model.
Use the dataset figure to see why a downward-opening curve calls for polynomial regression. section 4.14


