numpy polynomial interpretation

Viewed 34

I am using Polynomial.fit and get the following polynomial:

polynomial.str() '0.8447708645677164 - 0.09751307764485126 x1 - 0.039531273903863295 x2'

but when I perform

polynomial(0), it shows 0.9027526683087044.

But I thought if we input 0 into x, shouldn't it be 0.8447708645677164 instead?

1 Answers

This is the corrrect way

import numpy as np

p = [-0.039531273903863295, -0.09751307764485126, 0.8447708645677164 ]
val = np.polyval(p, 0)
print(val)

output 0.8447708645677164

Related