Databricks Machine Learning Associate Question 96
Single answerYou are using the MLflow Client API to identify the best run from an experiment based on a specific metric. Given the following use case: You want to select the run with the highest value for the 'accuracy' metric from an experiment named 'customer_churn_experiment'. Which approach should you take?
- A
Use the 'search_runs' method with an order_by parameter to sort by 'metrics.accuracy DESC' and retrieve the first run.
- B
Use the 'get_run' method to fetch all runs and manually iterate over them to find the run with the highest 'accuracy'.
- C
Use the 'log_metric' method to record the accuracy values for all runs and then sort the results.
- D
Use the 'create_experiment' method to create a new experiment with only the runs having the highest accuracy.
Show answer and explanation
Correct answer: A
Explanation
The 'search_runs' method in the MLflow Client API is specifically designed to query runs from an experiment based on defined criteria like metrics or parameters. By using the 'order_by' parameter with 'metrics.accuracy DESC', you can efficiently sort runs and select the one with the highest 'accuracy' metric. This approach is both efficient and aligns with MLflow's intended functionalities.
- A. Correct.
Correct. The 'search_runs' method allows you to query and sort runs based on specific metrics. Using 'metrics.accuracy DESC' ensures that the runs are sorted in descending order by accuracy, and the first entry would be the best run.
- B. Incorrect.
Incorrect. While 'get_run' can retrieve individual runs, it is inefficient and does not provide built-in sorting or filtering functionality. Manually iterating over runs is not optimal.
- C. Incorrect.
Incorrect. The 'log_metric' method is used to log metrics but cannot be used to retrieve or sort runs. It is unrelated to selecting the best run.
- D. Incorrect.
Incorrect. The 'create_experiment' method is for creating new experiments, not for filtering or sorting existing runs. This does not help in identifying the best run.