Home > OS >  Time series forecasting- wrong result
Time series forecasting- wrong result

Time:10-09

I haven't done any time-series forecasting before and I tried to forecast total call volume of data from a call center based on hourly datetime buckets. When I plot the forecast the data was correctly plotted but the forecast was way off.

enter image description here

Here's the code I used. It was similar to the one in getting started.


df.rename(columns={'date':'ds','count':'y'},inplace=True)
df["ds"] = pd.to_datetime(df["ds"])
new_data=df[['ds','y']]

#input data to prophet model and forecast 
model = Prophet()
model.fit(new_data)
future = model.make_future_dataframe(periods=15)
forecast = model.predict(future)
fig = model.plot(forecast, xlabel='ds', ylabel='y')
plt.title('forecasting')
plt.show()

And the data is being used,

       ds              y
2021-10-01 13:00:00   2871
2021-10-01 14:00:00   2545
2021-10-01 15:00:00   2426
2021-10-01 16:00:00   2446
2021-10-01 17:00:00    299

Want to know whether I haven't designed the prophet model properly, errors in the code or data format.

CodePudding user response:

You are working with non-daily data and you wan't to predict with hourly granularity but make_future_dataframe predict by default daily data as you can see on the prophet github.

Use model.make_future_dataframe(periods=15*24, freq='H') in your code to get the plot with hourly granularity for the next 15 days.

You can use the prophet documentation for non daily data.

  • Related