
September 11, 2026
11 min read
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.
mlflow.start_run() to log params, metrics, and artifacts. Register the best run in the Model Registry, then promote versions to Staging or Production for deployment.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.
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.
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.
- Create or select an experiment with
set_experiment. - Open a run with
start_runor nest child runs for cross-validation folds. - Log params once per run; log metrics per epoch or fold.
- Save the model with the flavor matching your framework.
- 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.
| Feature | Tracking only | Model Registry |
|---|---|---|
| Compare hyperparameters | Yes | Yes (via linked runs) |
| Version numbering | Run IDs only | Semantic model versions (v1, v2…) |
| Stage labels | No | Staging, Production, Archived |
| Approval workflow | No | Comments + transition history |
| Load model in serving | Manual artifact path | models:/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.
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./mlrunspath.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) No link between MLflow and the web app
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.
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?
| Tool | Best for | Hosting | Registry |
|---|---|---|---|
| MLflow | Self-hosted, multi-framework teams | Your VPS or cloud | Built-in Model Registry |
| Weights & Biases | Rich viz, collaborative research | SaaS (cloud) | W&B Model Registry |
| TensorBoard | TensorFlow / PyTorch training viz | Local or shared file | No 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/ProductionURIs. - 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
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.

