MLflow is an open-source platform for managing the full machine learning lifecycle β from experiment tracking and model packaging to registry management and production deployment. It sits at the center of modern MLOps workflows, giving data scientists a unified interface regardless of which framework (scikit-learn, PyTorch, TensorFlow, XGBoost, or LLMs) they use. The key mental model: every piece of work in MLflow is a run inside an experiment, every run can log params, metrics, and artifacts, and every trained artifact can be promoted to a versioned Model Registry β making any team's experiments reproducible, comparable, and deployable with minimal overhead.
What This Cheat Sheet Covers
This topic spans 20 focused tables and 142 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Tracking API β Runs and Experiments
The tracking API is the foundation of everything in MLflow. Understanding how to create experiments, start runs, and log data programmatically is the entry point before using autologging, the UI, or any advanced feature.
| Function | Example | Description |
|---|---|---|
mlflow.set_experiment("fraud-detection") | Sets the active experiment by name; creates it if it doesn't exist. All subsequent runs go into this experiment. | |
with mlflow.start_run(run_name="v1") as run: mlflow.log_param("lr", 0.01) | Opens a new tracking run as a context manager; automatically calls end_run() on exit, even if an exception is raised. Preferred over manual end_run(). | |
mlflow.log_param("n_estimators", 100) | Logs a single key-value hyperparameter (both as strings). Call once per param per run β duplicate keys are overwritten. | |
mlflow.log_params({"lr": 0.01, "epochs": 10}) | Logs multiple parameters at once from a dict; equivalent to calling log_param() in a loop but more efficient. | |
mlflow.log_metric("accuracy", 0.94, step=5) | Logs a numeric metric; optional step enables time-series charting in the UI. MLflow keeps the full history of values. | |
mlflow.log_metrics({"mae": 0.12, "rmse": 0.34}) | Logs multiple metrics simultaneously; accepts optional step and timestamp. | |
mlflow.set_tag("team", "nlp-squad") | Attaches a string metadata tag to the run; tags appear in the UI and are searchable with ILIKE. |