Tutorials and Examples
Welcome to our Tutorials and Examples hub! Here you'll find a curated set of resources to help you get started and deepen your knowledge of MLflow. Whether you're fine-tuning hyperparameters, orchestrating complex workflows, or integrating MLflow into your training code, these examples will guide you step by step.
🎯 Core Workflows & API
If you're focused on finding optimal configurations for your models, check out our Hyperparameter Tuning example. It walks you through setting up grid or random search runs, logging metrics, and comparing results—all within MLflow's tracking interface.
When your project requires coordinating multiple steps—say, data preprocessing, model training, and post-processing—you'll appreciate the Orchestrating Multistep Workflows guide. It demonstrates how to chain Python scripts or notebook tasks so that each stage logs artifacts and metrics in a unified experiment 🚀.
For those who prefer crafting HTTP requests directly, our Using the MLflow REST API Directly example shows you how to submit runs, retrieve metrics, and register models via simple curl
and Python snippets 🔍. It's ideal when you want language-agnostic control over your tracking server.
Meanwhile, if you're building custom functionality on top of MLflow's core, dive into Write & Use MLflow Plugins to learn how to extend MLflow with new flavors, UI tabs, or artifact stores. You'll see how to package your plugin, register it, and test it locally before pushing to production.
📦 Reproducibility & Supply Chain Security
Reproducibility is at the heart of trustworthy ML. If you need to encapsulate your entire training environment, the Packaging Training Code in a Docker Environment tutorial shows you how to create a Docker image that includes your data loader, training script, dependencies, and MLflow tracking calls. You'll see how to build, push, and run the image while capturing every artifact.
When protecting your Python packages from tampering, the Python Package Anti-Tampering example walks you through signing wheels, verifying checksums, and integrating these steps into your CI/CD pipeline. This ensures that what you log as code is exactly what you execute later, avoiding “works on my machine” surprises.
🛠️ Instrumenting ML Training Code
MLflow seamlessly integrates with a wide variety of training frameworks so you can log parameters, metrics, and artifacts with minimal boilerplate. Below is a narrative of framework-specific examples—click the ones relevant to your stack:
- Classic ML & Boosting: If you use H2O, see our H2O integration; for tree-based models, there's a complete XGBoost example that logs
DMatrix
parameters and feature importance plots. - Deep Learning: For neural nets, check out Keras, PyTorch, and TensorFlow examples—each one shows you how to instrument training loops, save model checkpoints, and visualize learning curves in the MLflow UI.
- Time Series Forecasting: Dive into Prophet or Pmdarima to learn how to log seasonal component plots and forecast accuracy metrics. You'll see how MLflow captures model snapshots for each tuning run.
- Statistical Models & R Users: If you're in R, explore Glmnet (R) where you'll fit elastic net models on the Wine dataset and log coefficients, cross-validation metrics, and model objects. For Python statistics, check out Statsmodels to see how to log OLS summaries and diagnostic plots.
- NLP & Transformers: Our SpaCy example walks you through training a text-classification pipeline, logging token embeddings and evaluation metrics. For large language models, the Transformers integration shows you how to log Hugging Face model weights, sample generations, and evaluation scores—all within MLflow's tracking UI.
- Explainability & Interpretability: Want to understand your model's predictions? The SHAP tutorial demonstrates how to compute SHAP values during training and visualize feature attributions in the MLflow UI.
- Advanced AI Workflows: For orchestration of LLM-based pipelines, explore LangChain and OpenAI examples. You'll instrument prompts, log completions, and track conversation histories alongside downstream evaluation metrics.
- Other Frameworks & Tools:
- LightGBM for fast gradient boosting.
- Diviner for time series anomaly detection.
- SynapseML to see how MLflow integrates with Azure Synapse pipelines.
- scikit-learn Examples:
- Diabetes example that fits an Elastic Net model and tracks metrics.
- Elastic Net example showcasing model packaging and hyperparameter logging.
- Logistic Regression example illustrating classification metrics and model registries.
- RAPIDS: If you leverage GPU-accelerated libraries, check out the Random Forest Classifier example, which logs GPU-based training metrics and model artifacts.
🔗 Getting Started
-
Choose Your Workflow: If hyperparameter search is your priority, start with the Hyperparameter Tuning example. For orchestrating multi-step pipelines, follow the Orchestrating Multistep Workflows guide. If you need a language-agnostic approach, explore the Using the MLflow REST API Directly tutorial.
-
Ensure Reproducibility & Security: Package your training code inside Docker by following Packaging Training Code in a Docker Environment. Protect your Python dependencies with our Python Package Anti-Tampering example.
-
Instrument Your Code: Browse the framework-specific examples above to identify which integration aligns with your stack. Click the relevant link (e.g., Keras for TensorFlow-based models, XGBoost for tree-based learners, or LangChain for LLM workflows).
-
Extend & Customize: To write and test custom plugins, consult Write & Use MLflow Plugins.
Start exploring these examples today to accelerate your MLflow journey—happy experimenting! 🚀