Databricks Machine Learning Professional Question 78
Select 2You are working on a Databricks project where you have trained a new version of a machine learning model, and you want to programmatically register it in the Databricks Model Registry. Which of the following steps are necessary to successfully register the new model version?
- A
Load the trained model as a PyFunc model and call the
mlflow.register_modelfunction with the model's URI and desired model name. - B
Specify the model name and call the
mlflow.register_modelfunction with the model's URI. - C
Use the
mlflow.log_modelfunction to log the model to MLflow first, and then use themlflow.register_modelfunction to register it. - D
Use the
mlflow.models.Model.registerfunction to directly register the trained model in the Model Registry. - E
Log the model using
mlflow.log_modeland then use themlflow.client.MlflowClient.create_registered_modelmethod to register it.
Show answer and explanation
Correct answers: B, C
Explanation
To programmatically register a new model version in the Databricks Model Registry, the model must first be logged to MLflow using mlflow.log_model. Once logged, the mlflow.register_model function can be used to register the model to the registry by specifying the model's URI and a desired model name. These steps ensure the model version is properly tracked and registered.
- A. Incorrect.
Incorrect: There is no need to load the model as a PyFunc model before using the
mlflow.register_modelfunction. The model URI is sufficient for registration. - B. Correct.
Correct: The
mlflow.register_modelfunction requires the model's URI and the desired model name to register a new version in the Model Registry. - C. Correct.
Correct: Before registering a model, it must be logged to the MLflow tracking server using
mlflow.log_model. Registration happens after logging. - D. Incorrect.
Incorrect: The
mlflow.models.Model.registerfunction does not exist in the MLflow API. This is an invalid option. - E. Incorrect.
Incorrect: While
mlflow.client.MlflowClient.create_registered_modelcan create a new registered model, it does not register a specific model version to the registry. It is not the correct method for this use case.