Run Statsforecast with MLFlow.MLFlow is an open source experiment tracking system that helps data scientists manage the model lifecycle from experimentation to production. An MLFlow integration for statsforecast is available in the MLFlow library that contains MLFlow support for popular machine learning libraries.
| unique_id | ds | y | static_0 | |
|---|---|---|---|---|
| 0 | 0 | 2000-01-01 | 12.073897 | 43 |
| 1 | 0 | 2000-01-02 | 59.734166 | 43 |
| 2 | 0 | 2000-01-03 | 101.260794 | 43 |
| 3 | 0 | 2000-01-04 | 143.987430 | 43 |
| 4 | 0 | 2000-01-05 | 185.320406 | 43 |
mlflow and mlflavors are needed. Install them
with:
Model Logging
Viewing Experiment
To view the newly created experiment and logged artifacts open the MLflow UI:Loading Statsforecast Model
Thestatsforecast model can be loaded from the MLFlow registry using
the mlflow.statsforecast.load_model function and used to generate
predictions.
| ds | AutoARIMA | AutoARIMA-lo-90 | AutoARIMA-hi-90 | |
|---|---|---|---|---|
| unique_id | ||||
| 0 | 2000-02-13 | 55.894432 | 44.343880 | 67.444984 |
| 0 | 2000-02-14 | 97.818054 | 86.267502 | 109.368607 |
| 0 | 2000-02-15 | 146.745422 | 135.194870 | 158.295975 |
| 0 | 2000-02-16 | 188.888336 | 177.337784 | 200.438904 |
| 0 | 2000-02-17 | 231.493637 | 219.943085 | 243.044189 |
Loading Model with pyfunc
Pyfunc is another interface for MLFlow models that has utilities for loading and saving models. This code is equivalent in making predictions as above.| ds | AutoARIMA | AutoARIMA-lo-90 | AutoARIMA-hi-90 | |
|---|---|---|---|---|
| unique_id | ||||
| 0 | 2000-02-13 | 55.894432 | 44.343880 | 67.444984 |
| 0 | 2000-02-14 | 97.818054 | 86.267502 | 109.368607 |
| 0 | 2000-02-15 | 146.745422 | 135.194870 | 158.295975 |
| 0 | 2000-02-16 | 188.888336 | 177.337784 | 200.438904 |
| 0 | 2000-02-17 | 231.493637 | 219.943085 | 243.044189 |
Model Serving
This section illustrates an example of serving thepyfunc flavor to a
local REST API endpoint and subsequently requesting a prediction from
the served model. To serve the model run the command below where you
substitute the run id printed during execution training code.
| ds | AutoARIMA | AutoARIMA-lo-95 | AutoARIMA-lo-90 | AutoARIMA-hi-90 | AutoARIMA-hi-95 | |
|---|---|---|---|---|---|---|
| 0 | 2000-02-13T00:00:00 | 55.894432 | 42.131100 | 44.343880 | 67.444984 | 69.657768 |
| 1 | 2000-02-14T00:00:00 | 97.818054 | 84.054718 | 86.267502 | 109.368607 | 111.581390 |
| 2 | 2000-02-15T00:00:00 | 146.745422 | 132.982086 | 135.194870 | 158.295975 | 160.508759 |
| 3 | 2000-02-16T00:00:00 | 188.888336 | 175.125015 | 177.337784 | 200.438904 | 202.651672 |
| 4 | 2000-02-17T00:00:00 | 231.493637 | 217.730301 | 219.943085 | 243.044189 | 245.256973 |

