MLflow UI

MLflow provides a web interface for tracking experiments, comparing runs, and managing models.

Starting the UI

Local Development

# From any pipeline directory
mlflow ui --port 5000

With Custom Backend

mlflow server \
    --backend-store-uri sqlite:///mlflow.db \
    --default-artifact-root ./mlruns \
    --host 0.0.0.0 \
    --port 5000

With S3 Artifact Store

mlflow server \
    --backend-store-uri sqlite:///mlflow.db \
    --default-artifact-root s3://064592191516-mlflow/mlruns \
    --host 0.0.0.0 \
    --port 5000

UI Features

Experiments View

The experiments view shows all your ML experiments:

  • Experiment Name: Logical grouping of runs
  • Runs: Individual training runs
  • Metrics: Performance metrics over time
  • Parameters: Hyperparameters used

Run Comparison

Compare multiple runs side-by-side:

  1. Select runs using checkboxes
  2. Click “Compare”
  3. View metrics and parameters in a table
  4. Visualize with parallel coordinates plot

Artifacts

Each run stores:

  • Model files: Serialized model artifacts
  • Config files: Training configuration
  • Plots: Generated visualizations
  • Logs: Training logs

Model Registry

Register and version models:

  1. Navigate to a run
  2. Click “Register Model”
  3. Choose or create a model name
  4. Set stage: Staging, Production, Archived

Tracking API

Logging from Code

import mlflow

# Set tracking URI
mlflow.set_tracking_uri("http://localhost:5000")

# Set experiment
mlflow.set_experiment("my_experiment")

# Start a run
with mlflow.start_run():
    # Log parameters
    mlflow.log_param("learning_rate", 0.001)
    mlflow.log_param("epochs", 10)
    
    # Log metrics
    mlflow.log_metric("accuracy", 0.95)
    mlflow.log_metric("loss", 0.05)
    
    # Log model
    mlflow.sklearn.log_model(model, "model")

Auto-logging

Enable automatic logging for supported frameworks:

# TensorFlow
mlflow.tensorflow.autolog()

# Scikit-learn
mlflow.sklearn.autolog()

# PyTorch
mlflow.pytorch.autolog()

Remote Access

SSH Tunnel

Access MLflow on a remote server:

ssh -L 5000:localhost:5000 user@remote-server

Then open http://localhost:5000 locally.

Nginx Proxy

For production deployments, use Nginx:

server {
    listen 80;
    server_name mlflow.example.com;
    
    location / {
        proxy_pass http://localhost:5000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Best Practices

  1. Name experiments descriptively: Use names like fraud_detection_v2
  2. Tag runs: Add tags for easy filtering
  3. Log artifacts: Save plots, configs, and reports
  4. Use the model registry: For production model management
  5. Clean up old runs: Archive or delete unsuccessful experiments