MLflavors: A collection of custom MLflow flavors.
Project description
The MLflavors package adds MLflow support for some popular machine learning frameworks currently not considered for inclusion as MLflow built-in flavors. You can use this package just like MLflow built-in flavors to save and load your models. Some of the key benefits are listed below:
Save your trained model as an MLflow artifact
Load your model from MLflow for batch inference tasks
Serve your model for real-time inference to an endpoint in the cloud (e.g. Databricks, Azure ML, AWS Sagemaker, etc.) using MLflow built-in deployment tools
Get inspiration for creating your own MLflow custom flavor
The following open-source libraries are currently supported:
Framework
Tutorials
Category
Time Series Forecasting
Time Series Forecasting
Time Series Forecasting
Anomaly Detection
Synthetic Data Generation
The MLflow interface for the supported frameworks closely follows the design of built-in flavors.
Documentation
Usage examples for all flavors and the API reference can be found in the package documenation.
Installation
Installing from PyPI:
$ pip install mlflavors
Quickstart
Save an Orbit ETS model as an artifact to MLflow:
import mlflavors
from orbit.models import ETS
from orbit.utils.dataset import load_iclaims
df = load_iclaims()
test_size = 52
train_df = df[:-test_size]
test_df = df[-test_size:]
ets = ETS(
response_col="claims",
date_col="week",
seasonality=52,
seed=8888,
)
ets.fit(df=train_df)
mlflavors.orbit.save_model(
orbit_model=ets,
path="model",
)
Make a prediction loading the model from MLflow in native format:
loaded_model = mlflavors.orbit.load_model("model")
loaded_model.predict(test_df, decompose=True, store_prediction_array=True, seed=2023)
Make a prediction loading the model from MLflow in pyfunc format:
# Convert test data to 2D numpy array so it can be passed to pyfunc predict using
# a single-row Pandas DataFrame configuration argument
X_test_array = test_df.to_numpy()
# Create configuration DataFrame
predict_conf = pd.DataFrame(
[
{
"X": X_test_array,
"X_cols": test_df.columns,
"X_dtypes": list(test_df.dtypes),
"decompose": True,
"store_prediction_array": True,
"seed": 2023,
}
]
)
loaded_pyfunc = mlflavors.orbit.pyfunc.load_model("model")
loaded_pyfunc.predict(predict_conf)
Contributing
Contributions from the community are welcome, I will be happy to support the inclusion and development of new features and flavors. To open an issue or request a new feature, please open a GitHub issue.
Versioning
Versions and changes are documented in the changelog .
Development
To set up your local development environment, create a virtual environment, such as:
$ conda create -n mlflavors-dev python=3.9
$ source activate mlflavors-dev
Install project locally:
$ python -m pip install --upgrade pip
$ pip install -e ".[dev,docs]"
Install pre-commit hooks:
$ pre-commit install
Run tests:
$ pytest tests/unit --cov
Build Sphinx docs:
$ cd docs
$ make html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mlflavors-0.1.0rc1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72b2eb79b97ecd50a983b305ee7b170c2e0f917ae634ae4981cc4d11ea5145d4 |
|
MD5 | 65ea319e4d5a415bcdb4ef63b42f3a37 |
|
BLAKE2b-256 | 6c092dad6b3540bc5f762f86f08a669db71253306c696a8afc0abe2d40b2265b |