November 2018
Intermediate to advanced
556 pages
14h 42m
English
The following code loads the data, splits it into two parts as described previously, builds the model with the training data and, finally predicts production for the next 20 days:
from statsmodels.tsa.arima_model import ARIMAimport matplotlib.pyplot as pltimport pandas as pd# read the datasetdf = pd.read_csv('./data/data_refinery.csv')print(df.head)# splitting data-set between train and testy=df['crude_flow'].valuesn=len(y)s = int(len(y) * 0.7)train, test = y[0:s+1], y[s:n]# Evaluating ARIMAorder=order=(3,1,2)model = ARIMA(train, order)model_fit = model.fit(disp=0)# Forecastingprediction=model_fit.forecast(steps=n-s)[0]# Visualizationplt.plot(train,'y', label='train')plt.plot(range(s,n),test,'k', label='test') ...