Databricks Machine Learning Associate exam dumps

Databricks Machine Learning Associate practice question 99 of 656

Databricks Certified Machine Learning Associate. Associate level, Databricks. Free question with the correct answer and a full explanation.

Databricks Machine Learning Associate Question 99

Single answer

You are working on a machine learning experiment in Databricks and have logged multiple runs using MLflow. You want to programmatically identify the run with the best performance (lowest validation loss) using the MLflow Client API. Which of the following code snippets correctly identifies the best run by fetching all runs from an experiment?

  1. A

    best_run = sorted(client.search_runs(experiment_id, "metrics.validation_loss IS NOT NULL"), key=lambda run: run.data.metrics['validation_loss'])[0]

  2. B

    best_run = max(client.list_run_infos(experiment_id), key=lambda run: run.data.metrics['validation_loss'])

  3. C

    best_run = min(client.search_runs(experiment_id, "metrics.validation_loss IS NOT NULL"), key=lambda run: run.data.metrics['validation_loss'])

  4. D

    best_run = client.get_run(experiment_id, order_by=['metrics.validation_loss ASC'])[0]

Show answer and explanation

Correct answer: C

Explanation

The MLflow Client API provides the search_runs method to query runs from an experiment. To identify the best run based on the lowest validation loss, it is best to use the min function with a key that accesses the 'validation_loss' metric. This approach ensures that you efficiently identify the desired run without unnecessary sorting or incorrect method usage.

  • A. Incorrect.

    This option uses sorted to order the runs but does not use the min function for efficiency. While it appears correct at first glance, directly sorting all runs isn't the optimal or required approach to identify the best run.

  • B. Incorrect.

    This option incorrectly uses list_run_infos, which only retrieves metadata about runs and does not include metrics data such as 'validation_loss'. Therefore, it would not work for identifying the best run based on metrics.

  • C. Correct.

    This option correctly uses min on the output of search_runs with a filter for non-null validation_loss metrics and identifies the run with the lowest validation loss, making it the correct answer.

  • D. Incorrect.

    This option attempts to use get_run with an incorrect argument (order_by), which is not a valid parameter for this method. The code would throw an error.

Timed practice exam

Take a Databricks Machine Learning Associate practice test under exam conditions

48 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam