Get the Polynomial Equation with Two Variables in Python
So you want to fit 6-th degree polynomial in python to your data?

Main thing you should note is that it will be still linear regression, its juts that predictors are polynomial (most important is that your weights are still linear (betas in lin.regression))

You can transform your features to polynomial using this sklearn module and then use these features in your linear regression model.

&gt; from sklearn.preprocessing import PolynomialFeatures from sklearn
&gt; import linear_model poly = PolynomialFeatures(degree=6)
&gt; poly_variables = poly.fit_transform(variables_length_wand_rate)
&gt; poly_var_train, poly_var_test, res_train, res_test = train_test_split(poly_variables, results,test_size = 0.3, random_state=4)
&gt; regression = linear_model.LinearRegression()  
&gt; model = regression.fit(poly_var_train,res_train)
&gt; score = model.score(poly_var_test, res_test)