Polynomial regression

In the previous examples, we assumed that the real relationship between the explanatory variables and the response variable is linear. In this section, we will use polynomial regression, a special case of multiple linear regression that models a linear relationship between the response variable and polynomial feature terms. The real-world curvilinear relationship is captured by transforming the features, which are then fit in the same manner as in multiple linear regression. For ease of visualization, we will again use only one explanatory variable, the pizza's diameter, in this section. Let's compare linear regression with polynomial regression using the following datasets:

Training instance

Diameter in inches ...

Get Mastering Machine Learning with scikit-learn - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.