ML Ops

See notebook arima_forecast.ipynb in the MLOps repo.

Codebase here: https://github.com/jed-gore/MLOps

A test case to begin to develop a reusable, scalable ARIMA module.

from statsmodels.tsa.statespace.sarimax import SARIMAX

PROCESS:

  1. Gather Data
  2. If not stationary – apply transformations
  3. d = number of times series is differenced
  4. List values of p and q
  5. Fit every combination in a loop –
  6. Select model with lowest AIC
  7. Observe residual analysis
  8. If uncorrelated residuals … we’re ready for forecasting!

Using Daloopa to pull data for AMZN (you will need to get your own API key):

image

We isolate Net Sales

image

And difference it twice to remove the trend and seasonality:

image

our ARIMA looks ok:

image

The ARIMA model looks better than naive seasonal:

image

and the MAPE (% error) is better:

image

So – this model appears to be useful for forecasting.

Citation: https://www.amazon.com/gp/product/B0BC9W1VBM/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1