• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Crypto Currency
  • Technology
  • Contact
NEO Share

NEO Share

Sharing The Latest Tech News

  • Home
  • Artificial Intelligence
  • Machine Learning
  • Computers
  • Mobile
  • Crypto Currency

Python Code on ARIMA Forecasting

January 31, 2021 by systems

Model Building

Let us build the model and analyse how well the values have translated into the model.

from statsmodels.tsa.arima_model import ARIMA
# ARIMA order (p,d,q)
model = ARIMA(df.Sales, order=(1,1,2))
model_fit = model.fit(disp=0)
print(model_fit.summary())

The model can be improved further and a lot of tuning can be done on it, but a point to note however is the small size of the series and thus limited accurate result.

Let us forecast and also look for accuracy,

model_fit.plot_predict(dynamic=False)
plt.show()

The results aren’t satisfactory, but it’s good to get an idea of how ARIMA works. Let’s do a quick accuracy metric check on the same to see how well can the model forecast future values.

import numpy as npmodel = ARIMA(train, order=(1, 1, 2))  
fitted = model.fit(disp=-1)
# Forecast
fc, se, conf = fitted.forecast(6, alpha=0.05)
mape = np.mean(np.abs(fc - test)/np.abs(test)) # MAPE

The MAPE is 17.99, that means the model’s accuracy is 82.11%.

Filed Under: Artificial Intelligence

Primary Sidebar

Stay Ahead: The Latest Tech News and Innovations

Cryptocurrency Market Updates: What’s Happening Now

Emerging Trends in Artificial Intelligence: What to Watch For

Top Cloud Computing Services to Secure Your Data

The Future of Mobile Technology: Recent Advancements and Predictions

Footer

  • Privacy Policy
  • Terms and Conditions

Copyright © 2025 NEO Share

Terms and Conditions - Privacy Policy