I made a model from a series of data. My model is represented by the red line which has the following formula:
p4=np.poly1d(np.polyfit(x,y,4)) #0.04253 x - 3.593 x + 89.6 x - 470.3 x + 666.4
How can I retrieve a value from my model (from the red polynomial line)?
I tried with this code but results are not coherent:
y=np.arange(len(x))
X=scale.fit_transform(y.values)
X=np.array(X)
X.reshape(-1,1)
est = sm.OLS(y, X).fit()
scaled = scale.transform(50)
predicted = est.predict(scaled[0])
With x=50 I retrieve 1 as prediction that's obviously not coherent with the model. Could you help me?
You can get the value by using the polynomial function returned by
np.poly1d.See the example shown in the documentation: