Deployment and MLOps#

This reference lists sktime integrations with deployment and MLOps solutions.

Currently, sktime natively supports integration with mlflow.

See examples/mlflow for a notebook tutorial.

MLflow#

sktime.utils.mlflow_sktime

The mlflow_sktime module provides an MLflow API for sktime forecasters.

This module exports sktime models in the following formats:

sktime (native) format

This is the main flavor that can be loaded back into sktime, which relies on pickle internally to serialize a model.

mlflow.pyfunc

Produced for use by generic pyfunc-based deployment tools and batch inference.

The pyfunc flavor of the model supports sktime predict methods predict, predict_interval, predict_proba, predict_quantiles, predict_var.

The interface for utilizing a sktime model loaded as a pyfunc type for generating forecasts requires passing an exogenous regressor as Pandas DataFrame to the pyfunc.predict() method (an empty DataFrame must be passed if no exogenous regressor is used). The configuration of predict methods and parameter values passed to the predict methods is defined by a dictionary to be saved as an attribute of the fitted sktime model instance. If no prediction configuration is defined pyfunc.predict() will return output from sktime predict method. Note that for pyfunc flavor the forecasting horizon fh must be passed to the fit method.

Predict methods and parameter values for pyfunc flavor can be defined in two ways: Dict[str, dict] if parameter values are passed to pyfunc.predict(), for example {"predict_method": {"predict": {}, "predict_interval": {"coverage": [0.1, 0.9]}}. Dict[str, list], with default parameters in predict method, for example {"predict_method": ["predict", "predict_interval"} (Note: when including predict_proba method the former approach must be followed as quantiles parameter has to be provided by the user). If no prediction config is defined pyfunc.predict() will return output from sktime predict() method.

get_default_pip_requirements([...])

Create list of default pip requirements for MLflow Models.

get_default_conda_env([include_cloudpickle])

Return default Conda environment for MLflow Models.

save_model(sktime_model, path[, conda_env, ...])

Save a sktime model to a path on the local file system.

log_model(sktime_model, artifact_path[, ...])

Log a sktime model as an MLflow artifact for the current run.

load_model(model_uri[, dst_path])

Load a sktime model from a local file or a run.