Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

MLflow: Track and Manage ML Experiments

By Kokil Thapa | Last reviewed: September 2026

MLflow: Track and Manage ML Experiments is the first tool I reach for when a client team outgrows scattered notebooks and spreadsheet metrics. Training runs multiply fast. Without a shared log, nobody knows which hyperparameters produced the model in staging. MLflow gives you a standard way to record parameters, metrics, artifacts, and registered models. This guide covers a production-minded setup you can run on a small Ubuntu server or inside Kubernetes. If you are wiring AI into a Laravel app, pair this with our AI integration and automation services so experiment results actually reach your API layer.

What is MLflow and why do teams use it to track ML experiments?

MLflow is an open-source platform for the full experiment lifecycle. It has four components that work together or stand alone.

  • Tracking — log runs with code, data snapshots, and environment details.
  • Projects — package training code so anyone can reproduce a run with one command.
  • Models — save models in a common format many serving tools understand.
  • Model Registry — version models, add stage labels, and attach approval notes.

Teams adopt it because it stays framework-agnostic. Scikit-learn, PyTorch, XGBoost, and Hugging Face all fit the same logging API. You are not locked into one cloud vendor. For Nepal-based startups on budget hardware, a single tracking server on a Rs 5,000/month VPS (~USD 37) often beats paying per-seat SaaS fees early on.

MLflow Platform OverviewTrackingParams, metricsProjectsReproducible runsModelsPyFunc formatRegistryStaging, ProdBackend Store + Artifact StorePostgreSQL or MySQL + S3 or local diskREST API + Web UI on port 5000
MLflow architecture: four components share a backend store and artifact storage for experiment tracking

The official docs at mlflow.org remain the source of truth for API changes. I treat MLflow as infrastructure, similar to how I treat Terraform state for IaC — one shared source everyone reads.

How do you install MLflow and start a tracking server?

MLflow runs on Python 3.9 or newer. Use a dedicated virtual environment so training deps do not pollute system Python.

Local quick start

python3 -m venv .venv
source .venv/bin/activate
pip install mlflow scikit-learn

export MLFLOW_TRACKING_URI=http://127.0.0.1:5000
mlflow server \
  --backend-store-uri sqlite:///mlflow.db \
  --default-artifact-root ./mlartifacts \
  --host 0.0.0.0 \
  --port 5000

Open http://127.0.0.1:5000 to browse experiments. SQLite suits solo dev work. Teams should move to PostgreSQL 18 or MySQL 9.7 for concurrent writes.

Production tracking server pattern

On Ubuntu 24 with Apache or Nginx in front, run MLflow under systemd. Point the backend at PostgreSQL and artifacts at S3-compatible storage.

mlflow server \
  --backend-store-uri postgresql://mlflow:secret@db-host:5432/mlflow \
  --default-artifact-root s3://my-bucket/mlflow-artifacts \
  --host 127.0.0.1 \
  --port 5000

Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the service unit. Never commit keys to Git. Use the same secret patterns described in AWS Secrets Manager for CI pipelines.

Experiment Tracking FlowTrain ScriptPython / notebookMLflow Clientlog_param, metricTracking ServerREST + metadataWeb UICompare runsArtifact Store: model.pkl, plots, config.yamlModel RegistryRegister best run, tag Staging or Production
How MLflow tracks experiments: training code logs to a server, artifacts land in object storage, UI enables comparison

How do you log parameters, metrics, and models in Python?

The Tracking API is small. Wrap your training loop in a run context. Log everything you might need to reproduce or defend a model choice.

import mlflow
import mlflow.sklearn
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import f1_score
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris

mlflow.set_tracking_uri("http://127.0.0.1:5000")
mlflow.set_experiment("iris-classifier-v1")

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

with mlflow.start_run(run_name="rf-baseline"):
    n_estimators = 100
    max_depth = 5
    mlflow.log_param("n_estimators", n_estimators)
    mlflow.log_param("max_depth", max_depth)

    model = RandomForestClassifier(
        n_estimators=n_estimators,
        max_depth=max_depth,
        random_state=42,
    )
    model.fit(X_train, y_train)
    preds = model.predict(X_test)
    f1 = f1_score(y_test, preds, average="macro")
    mlflow.log_metric("f1_macro", f1)

    mlflow.sklearn.log_model(
        model,
        artifact_path="model",
        registered_model_name="iris-rf",
    )

Each run gets a unique ID. The UI sorts by any logged metric. That beats grep-ing log files when you ran forty variants overnight.

Autolog for supported libraries

MLflow can capture params and metrics automatically for scikit-learn, PyTorch, and others.

import mlflow

mlflow.autolog(log_models=True)

Autolog is convenient for spikes. For client deliverables I still log business-specific tags manually — dataset version, feature pipeline hash, and data cutoff date.

  1. Create or select an experiment with set_experiment.
  2. Open a run with start_run or nest child runs for cross-validation folds.
  3. Log params once per run; log metrics per epoch or fold.
  4. Save the model with the flavor matching your framework.
  5. Register the artifact if it might reach production.

Validate logged JSON payloads with our JSON formatter tool before piping MLflow REST responses into dashboards.

How does the MLflow Model Registry compare to experiment tracking alone?

Tracking answers "what did we try?" The registry answers "which model is live, and who approved it?" Stages — None, Staging, Production, Archived — give ops a clear promotion path.

FeatureTracking onlyModel Registry
Compare hyperparametersYesYes (via linked runs)
Version numberingRun IDs onlySemantic model versions (v1, v2…)
Stage labelsNoStaging, Production, Archived
Approval workflowNoComments + transition history
Load model in servingManual artifact pathmodels:/name/Production URI

Promote a version from CLI or UI after validation passes.

client = mlflow.tracking.MlflowClient()
client.transition_model_version_stage(
    name="iris-rf",
    version=3,
    stage="Production",
    archive_existing_versions=True,
)

Load the production model anywhere the URI resolves.

model = mlflow.pyfunc.load_model("models:/iris-rf/Production")
predictions = model.predict(X_new)

This mirrors how I version REST APIs behind Laravel — immutable releases with a pointer to "current prod." See monitoring ML models for production drift for what to watch after promotion.

Model Registry Stage PromotionExperimentMany runs loggedRegisteredVersion v3 createdStagingQA + shadow testProductionLive inferenceRollback: archive prodPromote previous version
MLflow Model Registry promotion path from experiment runs through Staging to Production with rollback

How do you run MLflow on Kubernetes or alongside Kubeflow?

Single-node MLflow fits many agencies. When GPU jobs scale out, put the tracking server on a stable cluster service. Training pods set MLFLOW_TRACKING_URI to that internal DNS name.

Helm charts and community manifests exist, but the core requirement is always the same: persistent backend DB plus durable artifact storage. Do not store artifacts on ephemeral pod disks. I have seen teams lose a week of models that way.

For full pipeline orchestration, MLflow Tracking often sits beside Kubeflow pipelines on Kubernetes. Kubeflow schedules steps; MLflow records metrics from each step container. GPU scheduling details live in running AI/ML workloads on Kubernetes with GPUs.

Environment variables teams should standardize

  • MLFLOW_TRACKING_URI — server URL or local ./mlruns path.
  • MLFLOW_EXPERIMENT_NAME — defaults for CI batch jobs.
  • MLFLOW_RUN_ID — inject in CD to tie deployments to a run.
  • AWS_DEFAULT_REGION — required when artifacts use S3.

Wire these through GitLab CI variables the same way you wire app secrets. Add lint steps so a missing URI fails fast instead of silently writing to local disk on the runner.

What are common MLflow mistakes and how do you avoid them?

Most failures I debug are operational, not API-related.

Logging without tags or run names

Anonymous runs pile up. Use run_name plus tags like git_commit, dataset_hash, and author. Future you will thank present you.

Storing huge artifacts in the DB

The backend store holds metadata only. Large files belong in the artifact root. Keep plots and small configs in-repo if policy allows; store multi-GB checkpoints in object storage.

Skipping model signatures

Define input and output schema when logging. Serving tools validate payloads against it.

from mlflow.models.signature import infer_signature

signature = infer_signature(X_train, model.predict(X_train))
mlflow.sklearn.log_model(model, "model", signature=signature)

A registry entry nobody calls is shelfware. Expose inference through a FastAPI or Flask sidecar, then call it from Laravel via HTTP. Document the model URI in your internal API spec. Our API development practice treats model version headers as first-class metadata.

MLflow to Production Web AppMLflow Registrymodels:/prodInference APIFastAPI + pyfuncLaravel AppQueue + HTTP clientUserBrowserObservability LayerLog latency, error rate, model version headerAlert on drift vs baseline metrics
Connecting MLflow registered models to a Laravel application through an inference API with observability

Governance matters as models affect users. Read AI governance basics before automating decisions in production. Role clarity helps too — see AI engineer vs ML engineer vs data scientist.

How does MLflow compare to Weights & Biases and TensorBoard?

ToolBest forHostingRegistry
MLflowSelf-hosted, multi-framework teamsYour VPS or cloudBuilt-in Model Registry
Weights & BiasesRich viz, collaborative researchSaaS (cloud)W&B Model Registry
TensorBoardTensorFlow / PyTorch training vizLocal or shared fileNo native registry

I pick MLflow when the client wants data on their own PostgreSQL and S3 bucket. W&B wins for fast research sprints with pretty dashboards. TensorBoard stays in the loop for epoch-level loss curves during active training.

Cost control ties to experiment volume. Batch logging and early stopping save GPU hours — topics covered in AI rate limits and cost optimization. For eCommerce recommendation experiments, align offline metrics with business KPIs from eCommerce analytics KPIs you should track.

The GitHub repository at github.com/mlflow/mlflow shows release cadence and breaking changes. Pin the server and client to the same minor version in production.

Key Takeaways

  • Install MLflow, run a tracking server with PostgreSQL plus object storage before your team exceeds five concurrent experimenters.
  • Wrap every training job in mlflow.start_run(), log params and metrics explicitly, and tag runs with git SHA and dataset version.
  • Register promising models, promote through Staging to Production, and load via models:/name/Production URIs.
  • Connect the registry to a real inference API your Laravel or Symfony app can call — tracking alone does not ship value.
  • Monitor production models for drift and log the active MLflow version on every prediction response header.
  • Pin MLflow client and server versions, and treat the tracking URI as required CI/CD environment config.

People Also Ask

Can MLflow track deep learning experiments with PyTorch?

Yes. Install mlflow alongside PyTorch and call mlflow.pytorch.log_model() or enable mlflow.pytorch.autolog(). Metrics like loss and accuracy log per epoch. Artifacts include saved weights and optional TorchScript exports for serving.

Does MLflow require Databricks?

No. MLflow is open source and runs fully on your infrastructure. Databricks offers a managed MLflow experience, but the OSS server on Ubuntu, AWS, or Kubernetes is complete for most teams.

How do you search past MLflow runs programmatically?

Use MlflowClient().search_runs() with a filter string such as metrics.f1_macro > 0.85. Results include run IDs, params, and metrics. Automate promotion candidates in CI after tests pass.

Is MLflow enough for full MLOps?

MLflow covers tracking, packaging, and registry. You still need feature stores, orchestration, and monitoring. Pair it with Kubeflow or cron-based pipelines plus drift alerts for a practical MLOps stack without enterprise bloat.

Ship experiments that survive contact with production

MLflow: Track and Manage ML Experiments gives you reproducible training history and a registry your ops team can trust. Start with a shared tracking server, enforce tags and run names, and promote only models that pass staging checks. On legal-tech and eCommerce projects I have shipped, the win is not fancier algorithms — it is knowing exactly which model version answered last Tuesday's traffic spike.

Need help connecting experiment tracking to a production Laravel or API stack? Review our work on the Adventure Third Pole Trek booking platform and related custom software builds, then contact us to plan your MLflow deployment. For ongoing tuning after launch, testing and optimization services and AI-assisted debugging workflows close the loop between experiments and live traffic.

Frequently Asked Questions

MLflow is an open-source platform covering the full experiment lifecycle through four components: Tracking logs runs with code and environment details, Projects packages training code for one-command reproduction, Models saves models in a common serving format, and Model Registry versions models with stage labels and approval notes. Teams adopt it because it stays framework-agnostic—scikit-learn, PyTorch, XGBoost, and Hugging Face share the same logging API—and you are not locked into one cloud vendor. I treat it as shared infrastructure, similar to Terraform state: one source everyone reads when training runs multiply and spreadsheet metrics stop scaling.

MLflow runs on Python 3.9 or newer inside a dedicated virtual environment. Install with pip install mlflow, set MLFLOW_TRACKING_URI to your server URL, and start the server with mlflow server pointing --backend-store-uri at SQLite for solo work or PostgreSQL for teams, plus --default-artifact-root for file storage. Open port 5000 to browse experiments in the UI. For production on Ubuntu 24, run MLflow under systemd behind Apache or Nginx, bind to 127.0.0.1, point the backend at PostgreSQL, and store artifacts on S3-compatible object storage with credentials in the service unit—not in Git.

A single tracking server on a Rs 5,000/month VPS (~USD 37) often beats per-seat SaaS fees for Nepal startups on budget hardware.

No. MLflow is open source and runs fully on your infrastructure—a VPS, AWS, Ubuntu, or Kubernetes—without Databricks.

Wrap your training loop in mlflow.start_run(), optionally with a run_name. Call mlflow.log_param() once per hyperparameter, mlflow.log_metric() per epoch or evaluation fold, and save the trained model with the flavor matching your framework—mlflow.sklearn.log_model() for scikit-learn, for example. Use mlflow.set_experiment() to group related runs. Register promising models via registered_model_name so they appear in the Model Registry. For quick spikes, mlflow.autolog(log_models=True) captures params and metrics automatically for supported libraries, though I still add manual tags like dataset version and git commit for client deliverables.

Tracking answers what did we try—it records hyperparameters, metrics, and artifacts per run with unique run IDs. The Model Registry answers which model is live and who approved it. Tracking alone gives run IDs without semantic versioning; the registry adds model versions (v1, v2), stage labels (None, Staging, Production, Archived), comments, and transition history. You can compare hyperparameters in both, but only the registry gives a models:/name/Production URI that serving code loads directly. Promote a validated version from the UI or MlflowClient after staging checks pass, mirroring immutable API releases with a pointer to current production.

After logging a model with registered_model_name, it appears in the Model Registry with an initial None stage. Validate the version against your test suite, then transition it to Staging for pre-production checks. When ready, call client.transition_model_version_stage() with stage set to Production and archive_existing_versions=True to retire the prior live version. Load the promoted model anywhere with mlflow.pyfunc.load_model using the models:/name/Production URI. Document the active model URI in your internal API spec and include the MLflow version on prediction response headers so ops can trace which run answered a given request.

Yes. Install mlflow alongside PyTorch and call mlflow.pytorch.log_model() or enable mlflow.pytorch.autolog(). Metrics like loss and accuracy log per epoch. Artifacts include saved weights and optional TorchScript exports for serving.

Put the tracking server on a stable cluster service with a persistent PostgreSQL backend and durable artifact storage—never on ephemeral pod disks, where I have seen teams lose a week of models. Training pods set MLFLOW_TRACKING_URI to the internal DNS name of that service. Helm charts and community manifests exist, but the core requirement is always the same: backend DB plus object storage. For full pipeline orchestration, MLflow Tracking often sits beside Kubeflow Pipelines—Kubeflow schedules steps while MLflow records metrics from each step container. Standardize MLFLOW_TRACKING_URI, MLFLOW_EXPERIMENT_NAME, MLFLOW_RUN_ID, and AWS_DEFAULT_REGION across CI and training jobs.

Most failures I debug are operational, not API-related. Anonymous runs pile up without run_name and tags like git_commit, dataset_hash, and author—add them every time. Storing large checkpoints in the backend DB breaks performance; metadata stays in PostgreSQL while multi-GB artifacts belong in the artifact root or S3. Skipping model signatures means serving tools cannot validate payloads—use infer_signature when logging. A registry entry nobody calls is shelfware; expose inference through a FastAPI or Flask sidecar and call it from Laravel via HTTP. Pin client and server to the same minor version, and treat MLFLOW_TRACKING_URI as required CI config so runners do not silently write to local disk.

MLflow suits self-hosted, multi-framework teams wanting data on their own PostgreSQL and S3 bucket, with a built-in Model Registry. Weights and Biases wins for fast research sprints with rich collaborative dashboards, but it is SaaS-hosted with its own registry. TensorBoard stays useful for epoch-level loss curves during active TensorFlow or PyTorch training, yet it has no native registry and relies on local or shared files. I pick MLflow when the client wants full control on a VPS; W&B when visualization speed matters more than infrastructure ownership. Cost control ties to experiment volume—batch logging and early stopping save GPU hours regardless of which tool you choose.

Use MlflowClient().search_runs() with a filter string such as metrics.f1_macro > 0.85. Results include run IDs, params, and metrics. Automate promotion candidates in CI after tests pass.

MLflow covers tracking, packaging, and registry workflows well, but it is not a complete MLOps stack by itself. You still need feature stores, orchestration pipelines, and production monitoring for drift. Pair MLflow with Kubeflow or cron-based pipelines plus drift alerts for a practical setup without enterprise bloat. On projects I have shipped, the win is knowing exactly which model version handled last Tuesday's traffic spike—not fancier algorithms sitting untracked in a notebook. Connect the registry to a real inference API, monitor promoted models after launch, and log the active MLflow version on every prediction response.

MLflow tracking alone does not ship value to end users—a registry entry nobody calls is shelfware. Expose inference through a FastAPI or Flask sidecar that loads the production model via models:/name/Production, then call that endpoint from Laravel via HTTP the same way you would any REST integration. Document the model URI and version headers in your internal API spec. Validate logged JSON payloads before piping MLflow REST responses into dashboards. Read AI governance basics before automating user-facing decisions, and treat model version metadata as first-class response headers so support can trace which run produced a given prediction.

SQLite suits solo developer work via sqlite:///mlflow.db when you are the only person writing runs. Once your team exceeds roughly five concurrent experimenters, move to PostgreSQL 18 or MySQL 9.7 for concurrent writes—the backend store holds metadata only, not large model files. Production pattern on Ubuntu 24: point --backend-store-uri at postgresql://mlflow:secret@db-host:5432/mlflow and --default-artifact-root at s3://my-bucket/mlflow-artifacts. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the systemd service unit using the same secret patterns you use for CI pipelines. Never commit database or storage credentials to Git.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: