Databricks ML Associate Practice Question 12: Autolog Nested Runs
Databricks Certified Machine Learning Associate · Test 2 · question 2 of 10
A data scientist loops over 40 hyperparameter combinations, calling model.fit() once per combination in a Databricks notebook. They want each combination recorded as its own MLflow run so the runs can be sorted by validation metric, and they want all 40 grouped under a single run that represents the sweep. Parameters and metrics should be captured without hand-writing a log_param call for each one.
Which approach produces this structure?
Show answer and explanation
Answer:
Autologging instruments the training library, so each fit() call records that estimator's parameters, metrics and the model itself with no explicit logging code. Wrapping the loop in an outer mlflow.start_run() and opening each iteration with mlflow.start_run(nested=True) makes every combination a child run of one parent. The experiment UI then shows a single collapsible sweep whose children can be sorted and compared on the validation metric, which is exactly the requested structure.
Option A collapses the sweep into one run. A run holds one value per parameter key, so 40 different parameter sets cannot coexist in it; step distinguishes points in a metric's history, not distinct configurations, and the runs could not be sorted against each other.
Option B throws away the benefit of autologging and still yields a single run with one parameter set. Logging after the loop also records only whatever values the last iteration left behind.
Option C separates the runs but scatters them across 40 experiments, so they cannot be sorted or compared in one view. Experiments organise projects, not individual trials.
Reference: Databricks Autologging