Polynomial regression
I hope you are excited about the skills you have learned so far in this chapter. Now we are going to learn how to fit curves using linear regression. One way to fit curves using a linear regression model is by building a polynomial like this:
If we pay attention, we can see the simple linear model hidden in this polynomial. To uncover it, all we need to do is to make all the coefficients labeled higher than 1 exactly zero. And then we will get:
Polynomial regression is still linear regression, the linearity in the model is related to how the parameters enter in to the model, not the variables.
Let's try building a polynomial regression starting from the simpler polynomial model (after a constant and line), a parabola.
The third term controls the curvature of the relationship.
As a dataset, we are going to use the second group of the anscombe
quartet. We are going to upload this dataset from seaborn
and we are going to plot it.
ans = sns.load_dataset('anscombe') x_2 = ans...