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:
- Gather Data
- If not stationary – apply transformations
- d = number of times series is differenced
- List values of p and q
- Fit every combination in a loop –
- Select model with lowest AIC
- Observe residual analysis
- If uncorrelated residuals … we’re ready for forecasting!
Using Daloopa to pull data for AMZN (you will need to get your own API key):
We isolate Net Sales
And difference it twice to remove the trend and seasonality:
our ARIMA looks ok:
The ARIMA model looks better than naive seasonal:
and the MAPE (% error) is better:
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