Databricks Machine Learning Associate Question 124
Select 3You are training a machine learning model in Databricks and want to register the model using the MLflow Client API. Which of the following steps are correct for registering the trained model to the MLflow Model Registry?
- A
Use the
mlflow.register_model()function, providing the source path of the model and a model name. - B
Initialize an MLflow Client object using
mlflow.MlflowClient()and call itscreate_registered_model()method to create a model entry in the registry. - C
Use the MLflow Client's
create_model_version()method to create a specific version of the model, specifying the source path and model name. - D
Directly log the model using
mlflow.log_model()and it will automatically register in the MLflow Model Registry. - E
Query the model registry with the MLflow Client to confirm the registration using the
search_registered_models()method.
Show answer and explanation
Correct answers: B, C, E
Explanation
To register a model using the MLflow Client API, you must first initialize an MLflow Client object. Then, you can create a registered model entry using the create_registered_model() method. Afterward, you use the create_model_version() method to associate a specific version of the model with the registered model. Finally, it is good practice to confirm the registration by querying the model registry using search_registered_models(). Logging a model does not automatically register it, and there is no mlflow.register_model() method.
- A. Incorrect.
Incorrect: There is no
mlflow.register_model()function in the MLflow API. Registering a model requires using the MLflow Client or the MLflow Tracking UI. - B. Correct.
Correct: Initializing an
MlflowClientand using thecreate_registered_model()method is the correct way to create an entry in the MLflow Model Registry for your model. - C. Correct.
Correct: After creating a registered model, the
create_model_version()method is used to associate a specific model artifact with the registered model in the registry. - D. Incorrect.
Incorrect: Logging a model using
mlflow.log_model()will store the model artifacts in the experiment's tracking run, but it does not automatically register the model in the MLflow Model Registry. - E. Correct.
Correct: After registering the model, you can confirm its successful registration by querying the registry using the
search_registered_models()method.