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, 96 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
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. | ||
mlflow.set_tags({"env": "prod", "version": "2.1"}) | Sets multiple tags at once from a dict. | ||
run = mlflow.active_run(); print(run.info.run_id) | • Returns the currently active run object • returns None if no run is active• Useful when run ID is needed inside nested functions | ||
run = mlflow.last_active_run() | • Returns the most recently completed run, not just the active one • Useful after a with block ends | ||
exp = mlflow.get_experiment_by_name("fraud-detection") | • Retrieves an Experiment object by case-sensitive name • returns None if not found | ||
mlflow.create_experiment("new-exp", artifact_location="s3://my-bucket/") | • Creates a new experiment with optional custom artifact location and tags • returns the experiment ID string | ||
mlflow.set_tracking_uri("http://myserver:5000") | • Points the client at a remote tracking server • equivalent to setting MLFLOW_TRACKING_URI env var |