Jump to content

Python forecast predict help

Joveice

So I have followed this: https://medium.com/@josemarcialportilla/using-python-and-auto-arima-to-forecast-seasonal-time-series-90877adff03c

This is the guide I have manged to come the longest with.

My current issue is that I can't get the prediction to display on my chart, this is my code:

import pandas as pd
import plotly.plotly as ply
import matplotlib.pyplot as plt
from plotly.plotly import plot_mpl
from statsmodels.tsa.seasonal import seasonal_decompose
import cufflinks as cf
from pyramid.arima import auto_arima
import pickle

data = pd.read_csv('IPG2211A2N.csv', index_col=0)
data.head()
data.index = pd.to_datetime(data.index)
data.columns = ['Energy Production']
result = seasonal_decompose(data, model='multiplicative')
train = data.loc['1985-01-01':'2016-12-01']
test = data.loc['2017-01-01':]
with open('arima.pkl', 'rb') as pkl:
    stepwise_model = pickle.load(pkl)
future_forecast = stepwise_model.predict(n_periods=37)

future_forecast = pd.DataFrame(pd.Series(future_forecast), index=data.index, columns=['Prediction'])

pd.concat([data, future_forecast], axis=1).plot()
plt.show()

I have done the arima thing and since it takes so long time each time I saved it and load the file instead each time now.

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×