Hello Nixtla! Thanks for all you do with this ecos...
# statsforecast
c
Hello Nixtla! Thanks for all you do with this ecosystem I'm getting some transient warnings on
Naive()
fits on statsforecast 1.6.0 (and 1.5.0). Does this make sense to anyone? Details in đŸ§”
Round 1
Copy code
from statsforecast import StatsForecast
from statsforecast.models import Naive
naive_model = StatsForecast(models = [Naive()],
                            freq = 'MS',
                            n_jobs = 1)
naive_model.fit(X_naive_model)
Round 2: Run that code again Result: Same warning
Round 3: Immediately run a cell that gets 50 fits on fresh models
Copy code
for i in range(50):
    StatsForecast(models = [Naive()],
                                freq = 'MS',
                                n_jobs = 1).fit(X_naive_model)
Result: No warning
Round 4: Restart kernel. Run that loop of 50 fits again I get the warning once
Seems to happen when calculating sigma of residuals. I could imagine cases when we'd have a /0 or an NaN, but unsure why it happens inconsistently with new models on the same data any ideas?
j
Do you have series with a single data point?
c
I do yes! We are using
Naive()
on series with one data point, and
RandomWalkWithDrift()
on series with >1
j
I see. Then it's probably the division by zero. We should probably change that so that if n is zero sigma is 0 or similar. Can you open an issue for that? If you find that very annoying you could wrap the fit in a context manager that suppresses those warnings, e.g.
Copy code
import warnings

with warnings.catch_warnings():
    warnings.simplefilter('ignore', category=RuntimeWarning)
    naive_model.fit(...)
c
Got you! Warnings are nbd, but curious why does it happen consistently the first time(s) I fit a model on the same data, but not after?
j
It's probably related to the warnings themselves, because the divides by zero are still happening
c
That makes sense @José Morales ! Thanks for the super quick response as usual! I added the Issue as you suggested and took a swing at a PR https://github.com/Nixtla/statsforecast/issues/698 https://github.com/Nixtla/statsforecast/pull/699
j
That's awesome, thanks! Just a small request, can you move the if statement one line up? If we're going to set sigma to zero we can avoid the nansum and the squaring
c
Oh good call! Done