BUG - Cannot predict on using logistic -> All-NaN slice encountered
frbelotto opened this issue · 1 comments
frbelotto commented
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)
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
blacehoule commented
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?