Closed dkrantz closed 6 years ago
I'm not able to reproduce this issue when I fit with the bit of dataframe that you pasted and logistic trend. Could you give the full code/data that you use when you run into this issue so I can reproduce?
Ben:
Thanks for getting back to me. Code snippet below. Basically, I'm trying to get a forecast by state, so I'll parse out data by state and set cap/floor depending on which state it is:
states = pd.Series(list(app.index.get_level_values('state'))).unique()
for state in states: df = app[(app.index.get_level_values('state') == state) & (app.index.get_level_values('entered_app') >= pd.Timestamp('2016-01-01'))].reset_index() df.drop('state',axis=1,inplace=True) df = df.rename(columns={'entered_app' : 'ds', 'app_count' : 'y'})
if state == 'CA':
m = Prophet(daily_seasonality=True,changepoints=['2018-04-01'])
df['cap'] = 60
df['floor'] = 5
future_cap = 60
future_floor = 5
else:
m = Prophet(daily_seasonality=True)
df['cap'] = 160
df['floor'] = 25
future_cap = 160
future_floor = 25
m.fit(df)
future = m.make_future_dataframe(periods=120)
forecast = m.predict(future)
fig1 = m.plot(forecast)
fig2 = m.plot_components(forecast)
better formatting....
for state in states:
df = app[(app.index.get_level_values('state') == state) & (app.index.get_level_values('entered_app') >= pd.Timestamp('2016-01-01'))].reset_index()
df.drop('state',axis=1,inplace=True)
df = df.rename(columns={'entered_app' : 'ds', 'app_count' : 'y'})
#df['ds'] = df['ds'].dt.strftime('%B %#d')
if state == 'CA':
m = Prophet(daily_seasonality=True,changepoints=['2018-04-01'])
df['cap'] = 60
df['floor'] = 5
future_cap = 60
future_floor = 5
else:
m = Prophet(daily_seasonality=True)
df['cap'] = 160
df['floor'] = 25
future_cap = 160
future_floor = 25
m.fit(df)
future = m.make_future_dataframe(periods=120)
forecast = m.predict(future)
fig1 = m.plot(forecast)
fig2 = m.plot_components(forecast)```
would it be possible to post a csv of just the (filtered) dataframe df
that produces the error, so I can run the code on my machine?
sure, please see attached. note github won't let me upload csv, so I put it in excel format monthly_forecast_dump_20180625_1117.xlsx
After converting your xlsx to csv, I run the following code but do not get the error:
import pandas as pd
from fbprophet import Prophet
df = pd.read_csv('bad_plot_data.csv')
m = Prophet(daily_seasonality=True,changepoints=['2018-04-01'])
m.fit(df)
future = m.make_future_dataframe(periods=120)
forecast = m.predict(future)
fig1 = m.plot(forecast)
fig2 = m.plot_components(forecast)
fig2.show()
Can you verify that running the code I pasted produces the error for you? If so then it may be a matter of pandas/matplotlib versions. What version of matplotlib/pandas/numpy do you have?
import pandas
import matplotlib
import numpy
print(pandas.__version__)
print(matplotlib.__version__)
print(numpy.__version__)
I'd like to figure this out because we shouldn't raise exceptions like this, although in this particular case I suspect it is related to the daily_seasonality=True
input argument. Daily seasonality means seasonality over a 24-hour period, like afternoons have higher values than mornings. There's no daily seasonality when you have only one observation per day as is the case here, so you should leave that turned off.
Ben:
Here are my versions:
pandas version is 0.20.3 matplotlib version is 2.1.0 numpy version is 1.13.3
You were correct, removing the daily seasonality parameter removed the error. I wasn't understanding daily seasonaility correctly ( i thought it meant to expect variance from monday to tuesday to friday etc).
Glad to hear that was the issue, weekly seasonality will cover that type of cycle.
I would still like to find the source of the error, though, but haven't run into it yet even with those package versions. Could you confirm that the code I posted above produces the error for you?
Yep still does. See below:
ValueError Traceback (most recent call last)
Odd, what version of fbprophet do you have?
pandas version is 0.20.3 matplotlib version is 2.1.0 numpy version is 1.13.3 fb prophet version is 0.2.1
I've tried this in Windows with Anaconda3 and don't produce the issue there, in fbprophet 0.3. I think this has been fixed with the new release.
I'm getting an invalid format string error when calling fig2 = m.plot_components(forecast)
I'm getting no such error when calling fig1 = m.plot(forecast)
My dates are in YYYY-MM-DD format: ds y cap floor 0 2016-01-01 2 160 25 1 2016-01-02 6 160 25 2 2016-01-03 1 160 25 3 2016-01-04 15 160 25 4 2016-01-05 27 160 25
Is there a parameter that I should call that could override this?
Here is the full error:
ValueError Traceback (most recent call last)