Databricks Machine Learning Professional Question 79
Select 2You are working on a Databricks project where you have trained a machine learning model and saved it as a local artifact. Now, you want to programmatically register this model in the Databricks Model Registry as a new model. Which of the following steps must you include in your workflow to achieve this?
- A
Use the
mlflow.register_model()function to register the model in the Model Registry. - B
Log the model to MLflow using the
mlflow.log_model()function before attempting to register it. - C
Retrieve the model's run ID or artifact URI after logging, to use it during registration.
- D
Use the
mlflow.create_registered_model()function to register the model version directly. - E
Specify the stage (e.g., Staging or Production) as part of the registration process.
Show answer and explanation
Correct answers: B, C
Explanation
To programmatically register a new model or model version in the Databricks Model Registry, the workflow involves first logging the model to MLflow using mlflow.log_model() so that it is stored in MLflow's tracking system. After logging, you need to retrieve the run ID or artifact URI of the logged model to identify it during the registration process. Without these steps, the system cannot locate the specific model instance to register in the Model Registry. Other options either refer to non-existent functions or actions unrelated to the registration process.
- A. Incorrect.
The
mlflow.register_model()function does not exist. Instead, MLflow provides themlflow.register_model_version()or similar methods for registering models, but these are not directly used in this case. - B. Correct.
Logging the model using
mlflow.log_model()is an essential step because the model must be stored in MLflow's tracking system before it can be registered in the registry. - C. Correct.
The run ID or artifact URI is necessary to identify the specific instance of the model that needs to be registered in the Model Registry.
- D. Incorrect.
The
mlflow.create_registered_model()function is used to create a new registered model, not for registering a specific model version. This function is not typically used in this scenario. - E. Incorrect.
The stage (e.g., Staging or Production) is not specified during the registration process. Instead, you promote a registered model to a specific stage after registration.