Finding and comparing runs
Databricks Machine Learning Associate · Lesson 5 of 19 · 38:04
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Databricks Certified Machine Learning Associate exam. In this lesson: searching runs in code, filter strings and sorting, going from the best run to its model, and comparing runs side by side in the MLflow UI. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Three hundred runs
After a week of tuning, the demand experiment at Juniper Rides holds more than three hundred runs, and the team must pick the one model to send to production. Scrolling the run table is not an option, since the choice must be repeatable inside a job. This lesson covers how to find the best run with the MLflow API, and how to compare runs before choosing a model.
Searching runs
mlflow dot search_runs searches the runs of one or more experiments, given by their IDs or their names, and returns a pandas DataFrame, with one row per run. Its columns hold the run ID, the status, the start time, and one column for each metric, parameter, and tag, like metrics dot rmse, or params dot max_depth. The MlflowClient class offers the same search, and returns a list of run objects instead, with their data and their info. Both take a filter string, an order by list, and a maximum number of results. So the best run is the first row of a search sorted on the right metric, with a maximum of one result.
Filters and sorting
The filter string uses a syntax close to SQL, on metrics, parameters, tags, and attributes. Metrics compare as numbers, like metrics dot rmse less than 1.5, while parameters and tags compare as strings, in single quotes. Conditions combine with AND, and an attribute like the status keeps only the runs that finished. The order by list sorts on a column, ascending for an error, like the RMSE or the MAE, and descending for a score, like the AUC or R squared. And when a tuning job logs nested runs, the parent run ID tag narrows the search to that one job.
From the best run to its model
The search returns the run ID of the best run, and the model URI follows from it: runs, then the run ID, then the name of the model, or the ID of the logged model with MLflow 3. A job can then register that model, or first compare it with the current champion. With MLflow 3, search_logged_models also searches the logged models directly, by their parameters and metrics, which helps when one run evaluates several models. So in a pipeline, the selection is a query, not a person scrolling a table.
Comparing runs
Before production, a person usually compares the best candidates side by side. In the experiment, select two or more runs and choose Compare: the page shows their parameters and metrics in tables, and a toggle hides the values that are the same in every run. Charts show the differences, like a parallel coordinates plot that links each parameter to the metric, or a scatter plot of two values. Look beyond the main metric, since a run with a slightly better RMSE, but a much larger model, a longer training time, or worse results on an important segment, may not be the right choice. You can also compare runs from different experiments, for example a new model with the run of the production model. And the decision, with its reason, can be saved as a tag on the chosen run.
Recap
Let's recap. search_runs returns a pandas DataFrame of runs, and the client's search_runs returns run objects. The filter string compares metrics as numbers, and parameters and tags as quoted strings, with the status attribute to drop failed runs. The order by list sorts ascending for an error and descending for a score, and a maximum of one result gives the best run. The run ID leads to the model URI, which a job can register or compare with the champion. And the Compare page shows runs side by side, with charts, and a toggle that hides identical values.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
The team wants the best RMSE among the runs trained on the November data, which carry a data version tag equal to the month. Which filter string fits?
- params.data_version = '2026-11'
- tags.data_version = '2026-11'
- metrics.data_version = '2026-11'
- The condition in order_by
Show the answer
tags.data_version = '2026-11'
Tags are searched with the tags prefix, and compared as strings in single quotes. “params.data_version = '2026-11'” searches parameters, and the data version was logged as a tag. “metrics.data_version = '2026-11'” searches metrics, which hold numbers, not this text. And “The condition in order_by” puts the condition in the order by list, which only sorts the runs.
A tuning job runs four hundred trials, and some crash with an error before they log any metric. The selection step must ignore the crashed runs. What should the search add?
- max_results set to four hundred
- An order on the start time of each run
- A filter on the max_depth parameter
- A filter on the status attribute
Show the answer
A filter on the status attribute
A filter on the status attribute keeps only the runs that finished. “max_results set to four hundred” would return more runs, the crashed ones included. “An order on the start time of each run” would sort the runs by time, without removing any of them. And “A filter on the max_depth parameter” filters on a parameter, which the crashed runs share with the others.
A data scientist compares five runs, but most of their fifty parameters have the same value in every run, which hides the few that differ. What should the data scientist do?
- Turn on the toggle that hides identical values
- Delete the runs whose parameters are identical
- Search the runs again with max_results at five
- Log fewer parameters in the next runs
Show the answer
Turn on the toggle that hides identical values
The Compare page can hide the parameters and metrics that are identical in all the selected runs. “Delete the runs whose parameters are identical” would delete history that the team may need later. “Search the runs again with max_results at five” would return five runs, but not compare them. And “Log fewer parameters in the next runs” would only change future runs, and not help with these five.