3

My dataframe is in weekly level as below: sample

was trying to implement prophet model using the below code.

df.columns = ['ds', 'y']
# define the model
model = Prophet(seasonality_mode='multiplicative')
# fit the model
model1=model.fit(df)

model1.predict(10)

I need to predict the output in a weekly level for the next 10 weeks.How can I fix this?

I need to predict the output in a weekly level for the next 10 weeks.How can I fix this?

Unicorn
  • 43
  • 7

1 Answers1

4

You need to use model.make_future_dataframe to create new dates:

model = Prophet()
model.fit(df)

future = model.make_future_dataframe(periods=10, freq='W')

predictions = model.predict(future)

predictions will give predicted values for the whole dataframe, you can reach to the forecasted values for the next 10 weeks with simple indexing:

future_preds = predictions.iloc[-10:]
Nuri Taş
  • 3,828
  • 2
  • 4
  • 22
  • Can I ask you something? Periods=10 means? Next 10 week? – Unicorn Nov 21 '22 at 09:34
  • Sorry, there was a little mistake. You also need to state `freq` inside `make_future_dataframe` since `Prophet` assumes the dataframe has daily frequency by default. `Periods` stand for the number of rows by which a dataframe is extended. So when you set `periods=10, freq='W'` it adds 10 more rows with weekly frequency – Nuri Taş Nov 21 '22 at 10:36