Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
1 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
2 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
3 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
4 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
5 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
import pandas as pd
data = pd.read_csv(“Electric_Production.csv”,index_col=0)
[Link]()
[Link] = pd.to_datetime([Link])
6 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
[Link] = ['Energy Production']
import [Link] as ply
import cufflinks as cf
[Link](title="Energy Production Jan 1985--Jan 2018")
7 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
from [Link] import plot_mpl
from [Link] import seasonal_decompose
result = seasonal_decompose(data, model=’multiplicative’)
fig = [Link]()
plot_mpl(fig)
8 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
9 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
from [Link] import auto_arima
stepwise_model = auto_arima(data, start_p=1, start_q=1,
max_p=3, max_q=3, m=12,
start_P=0, seasonal=True,
d=1, D=1, trace=True,
error_action='ignore',
suppress_warnings=True,
stepwise=True)
print(stepwise_model.aic())
10 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
train = [Link]['1985-01-01':'2016-12-01']
test = [Link]['2017-01-01':]
stepwise_model.fit(train)
future_forecast = stepwise_model.predict(n_periods=37)
# This returns an array of predictions:
>>>print(future_forecast)
array([ 114.35302037, 105.67472349, 91.62172016, 93.11965624,
103.13943782, 112.0750119 , 110.28775882, 100.3846244 ,
92.76377402, 96.56146867, 110.15807481, 122.16905229,
111.76255057, 102.1074658 , 90.72177437, 92.21641046,
103.29671997, 112.53381746, 111.79663986, 101.28342664,
92.21562554, 95.42427613, 109.83787975, 118.78803148,
11 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
108.06504426, 101.03926634, 89.8586184 , 91.90975603,
102.9426644 , 112.42626585, 111.2655725 , 100.67041402,
92.32953027, 95.54048842, 110.86398308, 120.63508802,
108.74454694])
future_forecast = [Link](future_forecast,index =
[Link],columns=[‘Prediction’])
[Link]([test,future_forecast],axis=1).iplot()
12 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
[Link]([data,future_forecast],axis=1).iplot()
13 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
Sign Up for more Data Science
Get alerts for useful ar cles on Data Science and Machine Learning!
Sign up
I agree to leave [Link] and submit this informa on, which will be collected
and used according to Upscribe's privacy policy.
Powered by Upscribe
14 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
15 of 16 3/15/2021, 6:35 PM
Using Python and Auto ARIMA to Forecast Seasonal Time Series | by Jo... [Link]
16 of 16 3/15/2021, 6:35 PM