Created
July 26, 2017 07:51
-
-
Save shaunakpp/161e49270aee45899b5465695c4e9822 to your computer and use it in GitHub Desktop.
Prophet Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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