Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG - Cannot predict on using logistic -> All-NaN slice encountered #2575

Open
frbelotto opened this issue Apr 25, 2024 · 1 comment
Open

Comments

@frbelotto
Copy link

Hello guys,
I am trying to create some predictions over a historical sales data. Lets take this sample as dataframe:

import numpy as np
import pandas as pd
from datetime import date
from prophet import Prophet
from prophet.plot import plot_plotly, plot_components_plotly

dates = pd.date_range(date(2023,1,1),date(2023,12,31))
rng = np.random.default_rng()

df = pd.DataFrame({
    'ds' : dates,
    'y' : rng.random(len(dates)) * 100})

Now lets fit and predict

m = Prophet(growth='linear',daily_seasonality=True, weekly_seasonality=True, yearly_seasonality=True)
m.add_country_holidays(country_name='BR')
df['floor'] = 0
df['cap'] = 100
m.fit(df)
future = m.make_future_dataframe(periods=365,include_history=True,freq='D')
future['floor'] = df['floor']
future['cap'] = df['cap']
forecast = m.predict(future,vectorized=True)

And we got results!
Capturar

Now, lets make the code just changing to logistic

m = Prophet(growth='logistic',daily_seasonality=True, weekly_seasonality=True, yearly_seasonality=True)
m.add_country_holidays(country_name='BR')
df['floor'] = 0
df['cap'] = 100
m.fit(df)
future = m.make_future_dataframe(periods=365,include_history=True,freq='D')
future['floor'] = df['floor']
future['cap'] = df['cap']
forecast = m.predict(future,vectorized=True)

(I start to get this error!)

/projeto/libs/lib/python3.11/site-packages/numpy/lib/nanfunctions.py:1563: RuntimeWarning:
All-NaN slice encountered

And now there is no predict on results, only actual data.
Capturar2

@blacehoule
Copy link

I'm not sure that this is a bug. It looks like these might be historical conversion rates expressed in percentages, or something like that. If some of the percentages are 0% or 100%, which it looks like they are, you would get undefined behavior in the Logit transform. Maybe the program should fail more gracefully here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants