Search code examples
pythonforecastingfacebook-prophet

fbprophet Exponential Growth


So I currently have the following code where I am trying to forecast the number of electric vehicles miles in 30 years.

miles = [7851400, 22362800, 46612600, 78121800, 194901200, 416005800, 724719000, 1117932800, 1590637400, 2186914600]
years = []

for i in range(2010, 2020):
    years.append(i)
    
zipped_list = zip(years, miles)

EV_df = pd.DataFrame(list(zipped_list), columns = ['year', 'Electric Vehicles Miles'])
EV_df['year'] = pd.to_datetime(EV_df['year'], format='%Y')
EV_df[['y', 'ds']] = EV_df[['Electric Vehicles Miles', 'year']]

I then fit a prophet model and ask it to predict 30 years down the line.

ev_model = Prophet(weekly_seasonality=True)
ev_model.fit(EV_df)
future_electric = ev_model.make_future_dataframe(periods=30, freq='Y')
forecast_electric = ev_model.predict(future_electric)

However, the result is pretty much a linear trend where you can see how in the last 5 points it's starting to have some sort of exponential or massive increase in the number of miles which isn't really being recognized from the graph

enter image description here

How would I get it to recognize this spike and plot a smooth exponential graph and not assume it is linear?


Solution

  • You can also try changing your growth='linear parameter to growth='logistic' - which would handle exponetial or geometric growth. You would also need to add the saturation values if any.