Python implements polynomial regression

The linear regression method has a big limitation. It requires the assumption that there is a linear relationship behind the data. However, for practical application scenarios, there are too few data sets with a strong linear relationship, and more data with a nonlinear relationship. set. Here we introduce the use of polynomial regression and improve the linear regression method, which can predict the data. When learning linear regression, for some data, we want to find a straight line to fit the data as much as possible. If the data has only one feature, the corresponding straight line is y=ax+b, and x is the sample Features, a and b are the model parameters we need. But sometimes the data does not have this linear relationship, so the linear regression method cannot be used for prediction.

Specific examples are as follows:

 It is equivalent to transforming the original x feature into multiple x features. After adding these features, you can use (multiple) linear regression to better fit the original data, but in essence, we can find out our original features. non-linear curve.

Guess you like

Origin blog.csdn.net/hu_666666/article/details/127205421