Skip to main content

Community Model Flavors

MLflow's vibrant community has developed flavors for specialized ML frameworks and use cases, extending MLflow's capabilities beyond the built-in flavors. These community-maintained packages enable seamless integration with domain-specific tools for time series forecasting, anomaly detection, visualization, and more.

Quick Start​

Installing Community Flavors​

Most community flavors are available via PyPI:

# Time series forecasting
pip install mlflow[sktime]
pip install mlflavors

# Visualization and plotting
pip install mlflow-vizmod

# Big data and cloud platforms
pip install bigmlflow
pip install mlflow[aliyun-oss]

Basic Usage Pattern​

All community flavors follow MLflow's standard interface:

import mlflow
import community_flavor # Replace with actual flavor

# Train your model
model = SomeModel()
model.fit(data)

# Log with MLflow
with mlflow.start_run():
community_flavor.log_model(model, "model_path")

# Load for inference
loaded_model = community_flavor.load_model("model_uri")
predictions = loaded_model.predict(new_data)

Sktime​

Unified interface for time series forecasting, classification, and transformation.

pip install sktime[mlflow]
import pandas as pd
from sktime.datasets import load_airline
from sktime.forecasting.arima import AutoARIMA
from sktime.utils import mlflow_sktime

# Load data and train model
airline = load_airline()
model = AutoARIMA(sp=12, d=0, max_p=2, max_q=2, suppress_warnings=True)
model.fit(airline, fh=[1, 2, 3])

# Save and load with MLflow
mlflow_sktime.save_model(sktime_model=model, path="model")
loaded_model = mlflow_sktime.load_model(model_uri="model")

# Make predictions
predictions = loaded_model.predict()
print(predictions)

# Load as PyFunc for serving
loaded_pyfunc = mlflow_sktime.pyfunc.load_model(model_uri="model")
pyfunc_predictions = loaded_pyfunc.predict(pd.DataFrame())

MLflavors Package​

Support for multiple time series and ML frameworks in one package.

pip install mlflavors

Supported Frameworks:

FrameworkCategoryExample Use Case
OrbitTime SeriesBayesian forecasting
StatsForecastTime SeriesStatistical models
PyODAnomaly DetectionOutlier detection
SDVSynthetic DataPrivacy-preserving data generation

PyOD Anomaly Detection Example:

import mlflow
from pyod.models.knn import KNN
from pyod.utils.data import generate_data
import mlflavors

# Generate synthetic data
contamination = 0.1
n_train, n_test = 200, 100
X_train, X_test, _, y_test = generate_data(
n_train=n_train, n_test=n_test, contamination=contamination
)

with mlflow.start_run():
# Train KNN detector
clf = KNN()
clf.fit(X_train)

# Log model
mlflavors.pyod.log_model(
pyod_model=clf, artifact_path="anomaly_detector", serialization_format="pickle"
)

# Evaluate
scores = clf.decision_function(X_test)
mlflow.log_metric("mean_anomaly_score", scores.mean())

Serving PyOD Model:

# Load as PyFunc
loaded_pyfunc = mlflavors.pyod.pyfunc.load_model(model_uri="model_uri")

# Create configuration for inference
import pandas as pd

predict_conf = pd.DataFrame([{"X": X_test, "predict_method": "decision_function"}])

anomaly_scores = loaded_pyfunc.predict(predict_conf)[0]

Framework Support Matrix​

By Use Case​

Use CaseFrameworksInstallationKey Features
Time Series ForecastingSktime, Orbit, StatsForecastpip install sktime[mlflow]Unified API, multiple algorithms
Anomaly DetectionPyODpip install mlflavors40+ detection algorithms
VisualizationAltair, Plotly via VizModpip install mlflow-vizmodInteractive plots as models
Synthetic DataSDVpip install mlflavorsPrivacy-preserving data generation
Big Data MLBigMLpip install bigmlflowCloud-based supervised learning

Integration Patterns​

Most community flavors follow this pattern:

import mlflow
import community_flavor

# 1. Train your model
model = SomeFrameworkModel()
model.fit(training_data)

# 2. Log with MLflow
with mlflow.start_run():
community_flavor.log_model(
model=model,
artifact_path="model",
# Framework-specific parameters
serialization_format="pickle",
custom_config={"param": "value"},
)

# 3. Load for inference
loaded_model = community_flavor.load_model(model_uri)
predictions = loaded_model.predict(new_data)

# 4. Load as PyFunc for generic serving
pyfunc_model = community_flavor.pyfunc.load_model(model_uri)
generic_predictions = pyfunc_model.predict(input_dataframe)

Best Practices​

Development Guidelines​

  1. Follow MLflow Conventions - Implement save_model(), log_model(), load_model() functions. Add PyFunc flavor for generic inference. Include comprehensive error handling.

  2. Configuration Management - Use single-row DataFrames for complex inference parameters. Make all parameters JSON-serializable for REST API serving. Provide sensible defaults for optional parameters.

  3. Testing Strategy - Test save/load roundtrip functionality. Verify PyFunc compatibility. Test model serving with sample requests.

Performance Optimization​

# Efficient serialization for large models
def save_model(model, path, serialization_format="pickle"):
if serialization_format == "joblib":
# Use joblib for sklearn-compatible models
import joblib

joblib.dump(model, os.path.join(path, "model.joblib"))
elif serialization_format == "cloudpickle":
# Use cloudpickle for complex models with custom objects
import cloudpickle

with open(os.path.join(path, "model.pkl"), "wb") as f:
cloudpickle.dump(model, f)

Error Handling​

def load_model(model_uri):
try:
# Attempt to load model
return _load_model_internal(model_uri)
except Exception as e:
raise mlflow.exceptions.MlflowException(
f"Failed to load {FLAVOR_NAME} model. "
f"Ensure model was saved with compatible version. Error: {str(e)}"
)

Community Resources​

Contributing New Flavors​

  1. Create GitHub Repository - Follow naming convention: mlflow-{framework}. Include comprehensive documentation. Add example notebooks.

  2. Package Structure

    mlflow-myframework/
    β”œβ”€β”€ setup.py
    β”œβ”€β”€ README.md
    β”œβ”€β”€ mlflow_myframework/
    β”‚ β”œβ”€β”€ __init__.py
    β”‚ └── flavor.py
    β”œβ”€β”€ examples/
    β”‚ └── example_usage.ipynb
    └── tests/
    └── test_flavor.py
  3. Documentation Requirements - Installation instructions. Basic usage examples. API reference. Model serving examples.

Getting Help​

MLflow Discussions: GitHub Discussions. Community Slack: Join the MLflow community workspace. Stack Overflow: Tag questions with mlflow and framework name. Framework-Specific: Check individual flavor repositories for issues.


Ready to extend MLflow? Start by exploring the existing community flavors, then consider contributing your own flavor for frameworks not yet supported!