import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns palette=sns.color_palette() sns.set_theme() df=pd.read_csv('DUQ_hourly.csv', index_col='Datetime', parse_dates=True) df.info() fig,ax=plt.subplots(figsize=(12,8)) plt.title('Duquesne Light Co. Estimated Energe Consumption, 2005-2018',fontsize=16) df.plot(ax=ax) plt.ylabel('Energy Consumption (MW)') plt.legend(['Energy (MW)']); fig,ax=plt.subplots(figsize=(12,8)) plt.title('Duquesne Light Co. Estimated Energe Consumption, 2008-2010',fontsize=16) df.loc[(df.index<'1-1-2010') & (df.index>='1-1-2008')].plot(ax=ax) plt.ylabel('Energy Consumption (MW)') plt.legend(['Energy (MW)']); import prophet train=df.loc[df.index<'1-1-2016'] test=df.loc[df.index>='1-1-2016'] _,ax=plt.subplots() train.plot(ax=ax) test.plot(ax=ax,c=palette[1]) plt.legend(['train','test']) prophet_train=train.reset_index().rename(columns={'Datetime':'ds','DUQ_MW':'y'}) p=prophet.Prophet() p.fit(prophet_train) prophet_test=test.reset_index().rename(columns={'Datetime':'ds','DUQ_MW':'y'}) forecast=p.predict(prophet_test) _,ax=plt.subplots(figsize=(12,8)) test.plot(ax=ax) forecast['yhat'].plot(ax=ax) _,ax=plt.subplots(figsize=(12,8)) test.plot(ax=ax,color=palette[1]) p.plot(forecast,ax=ax); p.plot_components(forecast); forecast