Last active
March 21, 2019 03:28
-
-
Save conquistadorjd/189621647ff74253166186f333a2c59c to your computer and use it in GitHub Desktop.
fbprophet
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
00-fbprophet |
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
################################################################################################ | |
# name: 01_fbprophet_getting_started.py | |
# desc: Official tutorial | |
# date: NA | |
# Author: NA | |
################################################################################################ | |
import pandas as pd | |
from fbprophet import Prophet | |
print('*** Program Started ***') | |
### Impoting data as pandas dataframe | |
df = pd.read_csv('example_wp_log_peyton_manning.csv') | |
print(df.head()) | |
### Initiating new object Prophet & initiating fit method and passing input dataframe. Fitting should take 1-5 seconds | |
m = Prophet() | |
m.fit(df) | |
print("type of m" , type(m)) | |
### Extending data to few future dates | |
future = m.make_future_dataframe(periods=365) | |
print("type of future" , type(future)) | |
### The predict method will assign each row in future a predicted value which it names yhat | |
forecast = m.predict(future) | |
print("type of forecast" , type(future)) | |
# print(forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()) | |
### Plotting forecast | |
fig1 = m.plot(forecast) | |
# fig1.show() | |
fig1.savefig('01_fbprophet_getting_started-01.png') | |
### Plotting forecast components | |
fig2 = m.plot_components(forecast) | |
fig2.savefig('01_fbprophet_getting_started-02.png') | |
### Saving output excel | |
forecast.to_csv('example_wp_log_peyton_manning_output.csv', sep=',') | |
print('*** Program Completed ***') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment