Get the Polynomial Equation with Two Variables in Python TL;DR
predict &quot;price&quot;, given &quot;length&quot; and &quot;wandRate&quot;

I have some time-series data where the dependent variable is a polynomial result of 2 independent data points.
Here is a snippet:

This is past pricing data of Processed Rice Grains of a certain kind of rice.
Based on the variable &quot;wandRate&quot; (1st variable) which is the price for any &quot;length&quot; (2nd variable) over 8.2, prices of rice grains with lower lengths are calculated.
These prices are based on a long trial-and-error method of asking various experts on their &quot;opinion&quot; on how a certain grain of a certain length should be priced. There are other variables which can't be objectively measured, but length is the main indicator. I was wondering if it would be possible to create an objective model or find a polynomial equation in two variables to predict &quot;price&quot;, given &quot;length&quot; and &quot;wandRate&quot;
I was led to thinking in terms of a polynomial when I plotted the data in google sheets and a sixth-degree-polynomial equation gave an intuitively correct looking trendline.

NOTE: I do not have a strong math background so simple google searches about &quot;polynomial in 2 variables from data python equation&quot; did not yield any implementable results.

I'm looking for some python code to accomplish this. ANY guidance on where to look would be appreciated.
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)