Databricks Machine Learning Professional Question 77
Select 3You are working on a machine learning project in Databricks and have successfully trained a model. You want to programmatically register this model as a new version under an existing registered model in the Databricks Model Registry. Which of the following steps would you need to perform using the MLflow library?
- A
Use the
mlflow.set_experiment()function to associate the model with an experiment before registering it in the Model Registry. - B
Call the
mlflow.register_model()function with the model's run ID and the name of the registered model. - C
Invoke
mlflow.log_model()to log the model artifact before registering it in the Model Registry. - D
Use the
mlflow.models.Model.log()function to directly register the model as a new version. - E
Retrieve the existing model's name from the Model Registry and register the new version programmatically with
mlflow.register_model().
Show answer and explanation
Correct answers: B, C, E
Explanation
To programmatically register a new model version in the Databricks Model Registry using MLflow, you first need to log the model artifact using mlflow.log_model() so that it is tracked and stored. Then, you can use the mlflow.register_model() function to either register the model under a new name or create a new version under an existing registered model. Retrieving the model name is an optional but common step when working with existing registered models.
- A. Incorrect.
The
mlflow.set_experiment()function is used to set the experiment for tracking runs but is not relevant to the process of registering models in the Model Registry. - B. Correct.
The
mlflow.register_model()function is indeed used to register a model or create a new version under an existing registered model in the Model Registry. - C. Correct.
Before registering a model, it is necessary to log the model artifact using
mlflow.log_model()so that it is tracked and available for registration. - D. Incorrect.
The
mlflow.models.Model.log()function is not typically used for direct registration of models in the Model Registry; it is used for managing model metadata. - E. Correct.
Retrieving the existing model's name and using
mlflow.register_model()to programmatically register a new version is a valid approach for adding a model version to the registry.