MLflow Cheat Sheet
A reference for MLflow's experiment tracking, model registry, and CLI commands used to log, compare, and deploy machine learning models.
2 PagesIntermediateMar 18, 2026
Experiment Tracking
Log params, metrics, and artifacts for a run.
python
import mlflowmlflow.set_tracking_uri('http://localhost:5000')mlflow.set_experiment('my-experiment')with mlflow.start_run(): mlflow.log_param('lr', 0.01) mlflow.log_metric('accuracy', 0.92) mlflow.log_artifact('model.pkl') mlflow.sklearn.log_model(model, 'model')
CLI Commands
Common MLflow command-line operations.
bash
mlflow ui # Launch tracking UI (default :5000)mlflow run . -P alpha=0.5 # Run an MLproject entry pointmlflow models serve -m runs:/<run_id>/model -p 1234mlflow experiments listmlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root ./mlruns
Model Registry
Register and promote model versions.
python
from mlflow import MlflowClient# Register a run's model as a new model versionresult = mlflow.register_model('runs:/<run_id>/model', 'my-model')client = MlflowClient()client.transition_model_version_stage( name='my-model', version=3, stage='Production')
Core Components
The four pillars of the MLflow platform.
- Tracking- Logs parameters, metrics, artifacts, and source code for every training run
- Projects- Packages code with an MLproject file for reproducible, shareable runs
- Models- Standard packaging format supporting many flavors (sklearn, pytorch, xgboost, etc.)
- Model Registry- Central store for versioning models and managing stage transitions (Staging/Production/Archived)
- Autologging- mlflow.autolog() auto-captures params and metrics for supported frameworks with no manual logging
Pro Tip
Call mlflow.autolog() at the top of your training script before fitting a model — it automatically captures framework-specific parameters, metrics, and model artifacts for libraries like scikit-learn, XGBoost, and PyTorch Lightning without any manual log_param or log_metric calls.
Was this cheat sheet helpful?
Explore Topics
#MLflow#MLflowCheatSheet#DataScience#Intermediate#ExperimentTracking#CLICommands#ModelRegistry#CoreComponents#MachineLearning#DevOps#CommandLine#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance