A.B.
A.B.

Reputation: 83

How to make Monthly Predictions in R Facebook Prophet, Data is also Monthly

Data (df3) Looks like this. One "1" for day at the end was added just to fulfill date format requirement.

        ds           y<br/>
1  2015-01-01   -390217.2<br/>
2  2015-02-01    230944.1<br/>
3  2015-03-01    367259.7<br/>
4  2015-04-01    567962.8<br/>
5  2015-05-01    753175.6<br/>
6  2015-06-01   -907767.5<br/>
7  2015-07-01 -52225619.9<br/>
8  2015-08-01    631666.1<br/>
9  2015-09-01   -792896.8<br/>
10 2015-10-01    430847.6<br/>
11 2015-11-01   5159146.7<br/>
12 2015-12-01  -2087233.7

Code i have tried:

try <- prophet(df3, seasonality.mode = 'multiplicative')
future <- make_future_dataframe(try, periods = 1)
forecast <- predict(try, future)
tail(forecast)

Result i am getting:

           ds       yhat<br/>
50 2019-02-01 -9536258.7<br/>
51 2019-03-01  -456995.5<br/>
52 2019-04-01 -1734330.0<br/>
53 2019-05-01 -3428825.1<br/>
54 2019-06-01 -2612847.0<br/>
55 2019-06-02 -2918161.2

Question is how to predict July 2019 instead of 2nd june 2019 value?

Upvotes: 1

Views: 5474

Answers (2)

Rohan
Rohan

Reputation: 54

future = prophet.make_future_dataframe(periods=12 , freq='MS')

forecast = prophet.predict(future)
fig = prophet.plot(forecast)
fig.show()

MS stands for Month Start.

Upvotes: 0

Zeeshan
Zeeshan

Reputation: 1238

future = prophet.make_future_dataframe(periods=12 , freq='M')

for more information https://towardsdatascience.com/forecasting-in-python-with-facebook-prophet-29810eb57e66

Upvotes: 4

Related Questions