Skip to main content

MLflow: Experiment Tracking, Model Registry & Serving

MLflow is the open-source platform for managing the end-to-end ML lifecycle. Log experiments, version models, and deploy to production — all from a unified API that works with any framework.

✓ Framework-agnostic tracking ✓ Model Registry with lifecycle stages ✓ One-line autolog support ✓ Built-in REST serving
Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →

What is MLflow?

MLflow is an open-source platform created by Databricks (2018) that solves the reproducibility and management problem in ML: "which parameters produced my best model, and how do I get it back to production?" It provides a clean API for logging any training run, storing artifacts, and managing model versions through a standardized lifecycle.

MLflow is framework-agnostic — the same tracking API works whether you are training a scikit-learn pipeline, a PyTorch transformer, or a custom NumPy model. Runs are stored in a backend (local filesystem, PostgreSQL, MySQL) and artifacts in an artifact store (local disk, S3, GCS, Azure Blob).

Quickstart: Log Your First Run

Install MLflow with pip install mlflow, then wrap your training code in a run context:

import mlflow
import mlflow.sklearn
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score

mlflow.set_experiment("fraud-detection")

with mlflow.start_run(run_name="rf-baseline"):
    # Log hyperparameters
    params = {"n_estimators": 100, "max_depth": 8, "random_state": 42}
    mlflow.log_params(params)

    # Train
    clf = RandomForestClassifier(**params)
    clf.fit(X_train, y_train)

    # Log metrics
    acc = accuracy_score(y_test, clf.predict(X_test))
    mlflow.log_metric("accuracy", acc)
    mlflow.log_metric("f1_score", f1)

    # Log the model artifact
    mlflow.sklearn.log_model(clf, artifact_path="model")
    print(f"Run ID: {mlflow.active_run().info.run_id}")

Run mlflow ui to open the tracking dashboard at http://localhost:5000. Every run appears as a row with its params, metrics, and artifact links.

Autolog: Zero-Code Tracking

For supported frameworks, one line before training is enough:

import mlflow

# Enable autolog for all supported libraries at once
mlflow.autolog()

# Or per-library for fine-grained control
mlflow.sklearn.autolog(log_model_signatures=True)
mlflow.pytorch.autolog(log_every_n_epoch=5)
mlflow.xgboost.autolog()
mlflow.transformers.autolog()

# Training code unchanged — MLflow captures everything automatically
from sklearn.linear_model import LogisticRegression
model = LogisticRegression(C=0.5, max_iter=200)
model.fit(X_train, y_train)
# ✓ Params logged: C=0.5, max_iter=200, solver=lbfgs
# ✓ Metrics logged: training_score, validation metrics
# ✓ Model artifact saved automatically

Model Registry: Staging → Production Lifecycle

Register a model from a run, then manage its lifecycle programmatically:

from mlflow.tracking import MlflowClient

client = MlflowClient()

# Register model from a completed run
run_id = "abc123def456"
model_uri = f"runs:/{run_id}/model"
mv = client.create_model_version(
    name="FraudDetector",
    source=model_uri,
    run_id=run_id
)
print(f"Version: {mv.version}")  # Version: 3

# Transition through lifecycle stages
client.transition_model_version_stage(
    name="FraudDetector",
    version=3,
    stage="Staging",
    archive_existing_versions=False,
)

# After validation, promote to Production
client.transition_model_version_stage(
    name="FraudDetector",
    version=3,
    stage="Production",
    archive_existing_versions=True,  # archive old Production version
)

# Load production model anywhere
prod_model = mlflow.pyfunc.load_model("models:/FraudDetector/Production")

MLflow vs Weights & Biases vs Comet ML

Feature MLflow Weights & Biases Comet ML
Self-hostableYes (fully open-source)Enterprise onlyEnterprise only
Free tierUnlimited (self-hosted)100 GB freeLimited free
Model RegistryBuilt-inArtifacts + RegistryModel registry
Hyperparameter sweepsManual / Optuna pluginW&B Sweeps (excellent)Optimizer
Collaboration / ReportsBasic UIW&B Reports (excellent)Panels
Model servingmlflow models serveNone built-inNone built-in
Best forFull MLOps pipeline, self-hostedResearch teams, sweep-heavy workMid-size teams, good UI

Frequently Asked Questions

What are the four main components of MLflow?▼

MLflow has four core components: MLflow Tracking (log parameters, metrics, and artifacts per run), MLflow Projects (package ML code in a reproducible format with conda/docker environments), MLflow Models (a standard format for packaging models with a flavor abstraction), and MLflow Model Registry (a centralized store to manage model lifecycle with Staging, Production, and Archived stages).

How does MLflow Tracking differ from TensorBoard?▼

TensorBoard is tightly coupled to TensorFlow/Keras and excels at visualizing training curves. MLflow Tracking is framework-agnostic — it works with scikit-learn, XGBoost, PyTorch, HuggingFace, and custom code. MLflow also logs arbitrary artifacts (plots, CSVs, serialized models) and supports remote backends (S3, GCS, Azure Blob) alongside a full Model Registry, which TensorBoard lacks.

What is the MLflow Model Registry and when should I use it?▼

The Model Registry is a centralized store for managing ML model versions across their lifecycle. Use it when you have multiple model versions and need to track which version is in Staging vs Production, who approved a promotion, and what run produced the model. It integrates with CI/CD pipelines: an automated test can query models in Staging, validate them, then transition to Production via the API.

Can MLflow run without a remote tracking server?▼

Yes. By default MLflow logs to a local ./mlruns directory — no server required. For team use, deploy an MLflow tracking server with mlflow server --backend-store-uri postgresql://... --default-artifact-root s3://my-bucket/. Clients connect by setting the MLFLOW_TRACKING_URI environment variable. MLflow Databricks also provides a fully managed tracking server.

How does MLflow autolog work?▼

mlflow.autolog() automatically captures parameters, metrics, and model artifacts for supported libraries without any manual log calls. Call it before training: mlflow.sklearn.autolog() logs estimator params, CV metrics, and the fitted model. mlflow.pytorch.autolog() logs loss curves, optimizer state, and checkpoints. It is the fastest way to add tracking to existing training code.

How do I serve a registered MLflow model?▼

Use mlflow models serve -m models:/MyModel/Production -p 5001. This starts a REST endpoint that accepts JSON payloads and returns predictions. For production-scale serving, use mlflow.pyfunc.load_model() inside a custom FastAPI or BentoML service, or deploy the model to SageMaker/AzureML via built-in mlflow.sagemaker.deploy().