Databricks Machine Learning Professional Question 76
Select 2You are working on a machine learning project in Databricks and need to programmatically register a new model version after training a model. Which of the following steps are required to accomplish this using the MLflow library?
- A
Use the
mlflow.log_model()function to save the model locally before registering it. - B
Use the
mlflow.register_model()function to create a new model version. - C
Specify the model URI and model name while using the
mlflow.register_model()function. - D
Use the
mlflow.set_registry_uri()function to set the model registry location before registering the model. - E
Use the
mlflow.create_run()function to generate a new run ID for the registered model.
Show answer and explanation
Correct answers: B, C
Explanation
To programmatically register a new model version in Databricks, you must use the mlflow.register_model() function. This function requires you to provide the URI of the logged model (e.g., from mlflow.log_model()) and the name of the model in the Model Registry. Other functions, like mlflow.set_registry_uri() or mlflow.create_run(), are not part of the essential steps for registration.
- A. Incorrect.
Incorrect:
mlflow.log_model()is used to log the model artifact to an MLflow tracking server or local directory but does not handle model registration directly. - B. Correct.
Correct: The
mlflow.register_model()function is used to register a new model version in the MLflow Model Registry. - C. Correct.
Correct: When using
mlflow.register_model(), you must specify the model URI (location of the logged model) and a name for the model in the Model Registry. - D. Incorrect.
Incorrect: While the
mlflow.set_registry_uri()function can be used to set the registry URI in advanced setups, it is not required for registering a model if you're using the default registry location. - E. Incorrect.
Incorrect: The
mlflow.create_run()function is used to create a new run within an experiment but is not involved in the process of model registration.