has2k1 / scikit-misc

Miscellaneous tools for data analysis and scientific computing
https://has2k1.github.io/scikit-misc/stable
BSD 3-Clause "New" or "Revised" License
39 stars 9 forks source link

ValueError: b'Extrapolation not allowed with blending' #6

Closed javierrodenas closed 4 years ago

javierrodenas commented 4 years ago

Hi,

I am trying to predict the values in a sequence of days. I have fit my models with a range of days {day: 0 -> day: 50} and I would like to predict the day 51.

When I try to do it, it appears the following error:

ValueError: b'Extrapolation not allowed with blending'

Is there any way to predict using X that it has never seen before?

Thank you in davance

has2k1 commented 4 years ago

As you have not posted any code I cannot tell how you have used the package, but find a way to set surface='direct'.

javierrodenas commented 4 years ago

Hi,

here is the code:

from skmisc.loess import loess

lo = loess(X, y_log, span=0.1)
lo.fit()

days_to_predict = [51]
prediction = lo.predict(X)

plt.scatter(X, y_log, color='red', label="Original Data")
plt.plot(X, prediction.values, color='blue', label="Predicted")
plt.show()

The package is skmisc.loess but as I posted last time, it only predicts numbers that are in range (has already seen) but no numbers that it has never seen before....

has2k1 commented 4 years ago

The solution is

lo = loess(X, y_log, span=0.1, surface='direct')

See the documentation at loess_control.

javierrodenas commented 4 years ago

Hi @has2k1,

Thank you very much, it worked!

I am going to close the issue.