Polynomial Regression
Let’s move on and explore polynomial regression and spline interpolation. These methods extend the capabilities of traditional linear regression, allowing for more flexible modeling of complex relationships in data. By implementing these techniques, you can expand your toolbox of approaches to regression problems. This recipe allows us to model relationships that are exponential or curvilinear in nature.
Getting ready
We will look at two methods in this section: polynomial regression spline interpolation. We will create a new dataset to demonstrate these methods. Ideally, these methods are used when we have a dataset with a non-linear relationship between the features and the target. In order to create this dataset, we will use the make_regression()
function again, but this time we will add some non-linearity to the data by adding a sine wave and an exponential function to the target.
Load libraries:
import pandas as pd import matplotlib...