Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prophet Forecasting

My dataframe is in weekly level as below:

sample

I was trying to implement a prophet model using this 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?

like image 865
Unicorn Avatar asked Dec 06 '25 04:12

Unicorn


1 Answers

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:]
like image 53
Nuri Taş Avatar answered Dec 08 '25 18:12

Nuri Taş



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!