Skip to content

Instantly share code, notes, and snippets.

@shaunakpp
Created July 26, 2017 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaunakpp/161e49270aee45899b5465695c4e9822 to your computer and use it in GitHub Desktop.
Save shaunakpp/161e49270aee45899b5465695c4e9822 to your computer and use it in GitHub Desktop.
Prophet Demo
# import libraries
import pandas as panda_data_frame
import numpy as num_py
from fbprophet import Prophet
# create a data frame from the csv file, log-transform for normality
df = panda_data_frame.read_csv('clicks.csv')
df['y'] = num_py.log(df['y'])
df.head()
# feed data frame to prophet and set a prediction timespan
prophet = Prophet()
prophet.fit(df);
future = prophet.make_future_dataframe(periods=90)
forecast = prophet.predict(future)
# send the output to a csv file
forecast.to_csv('clicks-output.csv')
# plot forecast and trends
prophet.plot(forecast).savefig('prediction.png');
prophet.plot_components(forecast).savefig('trends.png');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment