Comparing Model Performance Across Jobs
This lesson explains how runs are compared in the studio and with MLflow, what makes a comparison fair, and which factors matter beyond the primary metric.
Learning outcomes
After completing this lesson, you will be able to:
- Describe how to compare runs in the studio and with MLflow.
- Identify the conditions for a fair comparison.
- Explain why latency, size and fairness matter.
- Describe automated comparison with the production model.
Comparing in the studio
In the studio, an experiment's run list shows each run's status, duration, parameters and metrics, and columns can be added, sorted and filtered. Selecting several runs opens a comparison view with their parameters and metrics side by side and charts of logged metrics, such as validation loss by epoch for each run. Custom charts, such as a scatter plot of learning rate against AUC, show relationships across many runs.
Sweep and automated ML jobs present their child trials in the same way, ranked by the primary metric. Automated ML adds a models list with each algorithm and its featurization, and an explanation of the best model where explanations are enabled.
Comparing with MLflow
mlflow.search_runs() returns a pandas DataFrame of runs that match a filter, which suits automated decisions in pipelines and workflows. Filters use parameters, metrics, tags and attributes, and results can be ordered by a metric.
import mlflow
runs = mlflow.search_runs(
experiment_names=["churn"],
filter_string="metrics.test_auc > 0.85 and tags.data_version = '3'",
order_by=["metrics.test_auc DESC"],
max_results=5,
)
print(runs[["run_id", "params.n_estimators", "metrics.test_auc"]])
best_run_id = runs.iloc[0]["run_id"]A training pipeline can end with a step that compares the new run with the current production model on the same test data, and registers the new model only if it is better by a meaningful margin.
What makes a comparison fair
Metrics from different runs can be compared only when the runs were evaluated the same way. A higher AUC on an easier test set says nothing about the model. The following conditions should hold before one run is declared better than another.
- The same test or validation data, ideally a fixed held-out data asset version, not a new random split per run.
- The same metric definitions and thresholds, computed by shared code.
- The same target and population, without leakage of future information into features.
- Enough difference to matter: small differences can be noise, which repeated runs with different seeds or confidence intervals reveal.
Beyond the primary metric
The best model by the primary metric is not always the one to register. Inference latency and cost, model size, interpretability, stability across cohorts, and fairness can outweigh a small gain in accuracy. A model that is 0.2 percent more accurate but ten times slower may fail a latency requirement, and one that performs much worse for one customer group may fail a responsible AI review.
An unfair comparison
A team compares two models. Run 1 reports an AUC of 0.89 and run 2 reports 0.93, so they plan to register run 2. Each training script calls train_test_split without a fixed random state, and run 2 used a newer data asset version that excludes customers with incomplete records.
The runs were evaluated on different test sets: different random splits and different populations. The comparison is not valid. Both models should be evaluated on the same fixed held-out data asset version that represents production, with shared evaluation code, and the results compared with mlflow.search_runs() or the studio. Excluding incomplete records may also make the test easier than production.
Registering run 2 because its number is higher ignores the evaluation difference. Averaging the two AUCs is meaningless. Retraining run 1 on the newer data version would still leave random splits and the changed population.
Two models are compared by AUC, but one was tested on a different month of data. Why is the comparison unreliable?
Show answer
A fair comparison needs the same test data, metric code and population. A different month may be easier or harder, so the difference in AUC may reflect the data, not the models.
Exam Tips
Remember for the exam
- Compare runs in the studio's comparison view or with mlflow.search_runs().
- Fair comparison needs the same test data, metric code and population.
- Weigh latency, size, fairness and stability, not only the primary metric.
- Automate the comparison against the production model before registering.