Monday, October 19, 2026
HomeData ScienceMLflow and Experiment Tracking – Model Registry, Runs and Lifecycle Management

MLflow and Experiment Tracking – Model Registry, Runs and Lifecycle Management

Table of Content

📋 KEY INSIGHTS

  • MLflow is the de facto standard open-source platform for the ML experiment lifecycle: tracking experiment parameters, metrics, and artefacts; managing the model registry; and serving registered models via a REST API. It integrates natively with scikit-learn, XGBoost, LightGBM, PyTorch, TensorFlow, and Hugging Face, auto-logging runs with a single line of code.
  • The four core components of MLflow are: Tracking (logging and querying experiments β€” parameters, metrics, tags, artefacts), Projects (packaging ML code in a reproducible format with a conda or Docker environment spec), Models (a standard model packaging format with a Python function flavour that any serving framework can consume), and Model Registry (a centralised model repository with versioning, stage transitions, and approval workflows).
  • A well-designed MLflow experiment structure separates concerns cleanly: one experiment per modelling task (e.g. “churn-prediction-v2”), one run per training attempt, nested runs for hyperparameter search (parent run holds the Optuna study, child runs hold individual trials), and logged artefacts that capture everything needed to reproduce the result β€” including the training data version, preprocessing pipeline, and model binary.
  • The MLflow Model Registry formalises the model promotion workflow: a model version is created from a run, assigned to a stage (Staging, Production, or Archived), and promoted or demoted by CI/CD pipelines that gate promotion on automated evaluation tests. This structured promotion path replaces ad-hoc model deployment practices and creates an audit trail of every model that ever reached production.
  • MLflow’s integration with Databricks (via Unity Catalog) and cloud MLOps platforms (AWS SageMaker, Azure ML, Vertex AI) means that the tracking and registry patterns learned with open-source MLflow transfer directly to managed enterprise deployments β€” the MLflow Python client is the same in all environments, only the tracking server URI and storage backend change.
  • Experiment tracking is not just bookkeeping β€” it is the foundation of reproducible ML. Without systematic tracking of every parameter, random seed, data version, and library version, reproducing a result that was achieved six months ago is practically impossible. MLflow (or an equivalent tool) should be set up before the first training run, not after the first reproducibility crisis.

Most data scientists have experienced the reproducibility crisis at first hand: a model that performed well last quarter cannot be reproduced because no one recorded which preprocessing steps were applied, which hyperparameters were used, which version of the training data was active, or which random seed produced the results. Experiment tracking β€” systematically recording everything that characterises an ML experiment β€” is the engineering practice that prevents this crisis. MLflow is the most widely adopted open-source tool for experiment tracking and the ML model lifecycle, with native integrations across every major ML framework and production deployment target. This guide covers the full MLflow ecosystem: the Tracking API, the Autolog feature, experiment organisation best practices, the Model Registry and stage transitions, model serving, and integration with hyperparameter optimisation, model deployment, and cloud MLOps platforms.

MLflow Tracking β€” Logging Runs and Experiments

An MLflow experiment is a named collection of runs β€” all attempts to solve a particular modelling problem. A run is a single training attempt, capturing: parameters (the configuration values β€” hyperparameters, preprocessing choices, model architecture decisions), metrics (the performance numbers β€” training loss, validation AUC, RMSE β€” which can be logged at each epoch for learning curves), tags (free-form metadata β€” who ran the experiment, what Git commit, what Jira ticket), and artefacts (binary files β€” the serialised model, plots, confusion matrices, feature importance charts, the training dataset as a reference). Everything logged to a run is stored in the tracking server backend β€” a local filesystem, a remote database + object store, or a fully managed service like Databricks Managed MLflow.

MLflow Autolog is the most important feature for adoption: calling mlflow.autolog() before training automatically logs all relevant parameters, metrics, and model artefacts for the active framework β€” scikit-learn, XGBoost, LightGBM, PyTorch Lightning, or Hugging Face Trainer β€” with no additional code. For gradient boosting models, autolog records every tree’s training and validation loss, the final hyperparameters, and the model binary. For neural networks, it records the epoch-level training and validation metrics as a time series. The result is a complete record of the training run without any manual logging calls, reducing the friction that prevents practitioners from tracking experiments consistently.

For custom logging β€” metrics computed outside the framework’s native training loop, custom artefacts like SHAP plots or calibration curves β€” the tracking API is clean and explicit:

with mlflow.start_run(run_name="lgbm-v3-tuned") as run:
    mlflow.log_params({"n_estimators": 500, "learning_rate": 0.05, "max_depth": 6})
    mlflow.log_metric("val_auc", 0.923)
    mlflow.log_metric("val_pr_auc", 0.741)
    mlflow.sklearn.log_model(pipeline, "model")          # saves the sklearn Pipeline
    mlflow.log_artifact("shap_summary.png")              # saves any file
    mlflow.set_tag("dataset_version", "2026-10-01")

Run IDs are returned by mlflow.start_run() and are permanent, unique identifiers β€” they are the primary key for referencing a run in the Model Registry, in CI/CD promotion scripts, and in audit trails. Connecting run IDs to the Git commit that produced them (logged automatically by MLflow’s Git integration) creates a complete chain of custody from source code to deployed model, directly supporting the data lineage and audit requirements that regulated industries impose.

MLflow ComponentPurposeKey APIStorage Backend
TrackingLog params, metrics, artefacts per runmlflow.log_param/metric/artifact, autologLocal filesystem, S3/GCS/ADLS, DB
ProjectsReproducible execution environmentsmlflow run, MLproject fileGit, local directory
ModelsStandard model packaging (flavours)mlflow.sklearn/pytorch/pyfunc.log_modelArtefact store
Model RegistryVersioning, stages, approval workflowMlflowClient.create_registered_model, transition_model_version_stageRegistry DB
ServingREST API from registered modelmlflow models serve, mlflow deploymentsModel artefact store

Model Registry β€” Versioning and Stage Transitions

a close up of a button on a wall
Photo by Google DeepMind on Unsplash

The MLflow Model Registry is a centralised catalogue of all registered models, their versions, and their current deployment stage. A registered model has a name (e.g. “churn-prediction”) and one or more versions, each created from a specific training run. Versions progress through stages: None (newly registered, under evaluation), Staging (passing automated evaluation tests, ready for user acceptance testing), Production (currently serving live traffic), and Archived (replaced by a newer version, retained for rollback).

The stage transition workflow is the operationalisation of the model lifecycle: after a training run, the best run is registered via mlflow.register_model(run_uri, "churn-prediction"). A CI/CD pipeline (GitHub Actions, GitLab CI, or Airflow β€” covered in our ETL pipelines guide) then automatically evaluates the new version against a held-out evaluation set and a set of behavioural tests β€” checking that predictions are in the expected range, that the model’s fairness metrics across demographic groups meet the ethical AI thresholds set by the team, and that the model’s latency meets the SLA. If all tests pass, the pipeline transitions the version to Staging via client.transition_model_version_stage("churn-prediction", version, "Staging"). A human reviewer approves the Staging-to-Production transition (or the pipeline does it automatically for lower-stakes models). The previously Production version is automatically Archived, available for instant rollback if the new version degrades in production.

Model aliases (introduced in MLflow 2.0) provide stable reference names β€” @champion for the current production model, @challenger for the staged candidate β€” that deployment code references without needing to know the specific version number. This decouples deployment code from version management: the serving infrastructure always loads the model tagged @champion, and the Registry handles which version that maps to. The connection to our model deployment guide is direct: MLflow’s model serving command launches a Flask REST API that loads the @champion model and serves predictions, and the containerised deployment workflow uses MLflow’s Docker image generation to package the model with its dependencies.

Integration with Hyperparameter Optimisation and AutoML

MLflow’s nested runs API integrates cleanly with Optuna, Ray Tune, and Hyperopt for systematic hyperparameter search with full experiment tracking. Each Optuna trial is a child run under a parent run representing the full hyperparameter search study. The parent run logs the best parameters and best metric; each child run logs its own parameters and validation metric. This structure makes the full search history queryable and visualisable in the MLflow UI β€” you can plot validation AUC against each hyperparameter, identify interactions between parameters, and compare the pareto front of accuracy vs. latency tradeoffs.

The MLflow tracking integration with Optuna requires fewer than 10 lines of callback code:

import optuna, mlflow

def objective(trial):
    with mlflow.start_run(nested=True):
        params = {"n_estimators": trial.suggest_int("n_estimators", 100, 1000),
                  "max_depth":    trial.suggest_int("max_depth", 3, 10)}
        mlflow.log_params(params)
        score = train_and_evaluate(params)
        mlflow.log_metric("val_auc", score)
    return score

with mlflow.start_run(run_name="optuna-search"):
    study = optuna.create_study(direction="maximize")
    study.optimize(objective, n_trials=100)
    mlflow.log_params(study.best_params)
    mlflow.log_metric("best_val_auc", study.best_value)

The resulting MLflow experiment contains 101 runs (1 parent + 100 trials), fully queryable. The best run can be registered directly from the parent run via the MLflow UI or API, entering the stage-transition workflow described above. This end-to-end pipeline β€” data preparation, feature engineering, hyperparameter search, experiment tracking, model registration, and deployment β€” is the core workflow described in our MLOps interview guide and is a standard expectation for senior data science roles as surveyed in our salary guide.

✦ SUMMARIZE THIS ARTICLE WITH AI

Hyperparameter optimisation with Optuna that integrates with MLflow tracking is in our AutoML guide. Model deployment via REST API and Docker β€” the downstream step after MLflow model registration β€” is in our Model Deployment guide. MLOps interview questions covering MLflow, model registries, and CI/CD pipelines are in our MLOps Interview guide. Data quality and lineage tracking that complement MLflow experiment tracking are in our Data Quality guide. The modern data stack that MLflow sits within β€” alongside dbt, Airflow, and feature stores β€” is in our Modern Data Architecture guide.

Leave feedback about this

  • Rating

Durgesh Kekare
Durgesh Kekarehttps://www.dataexpertise.in
Durgesh Kekare is a data science educator and founder of DataExpertise.in. With expertise in Python, machine learning, and analytics, he helps 10,000+ learners break into data careers.

Latest Posts

List of Categories