Databricks Machine Learning Associate Question 483
Single answerA data scientist has registered a machine learning model in the Databricks Model Registry. They now want to add a tag to the model to indicate its intended use case as 'Production'. Which of the following code snippets correctly sets the tag for the model?
- A
mlflow.set_tag('use_case', 'Production')
- B
mlflow.register_model_tag('use_case', 'Production', model_name='my_model')
- C
from mlflow.tracking import MlflowClient; MlflowClient().set_registered_model_tag(name='my_model', key='use_case', value='Production')
- D
from mlflow.tracking import MlflowClient; MlflowClient().set_tag('use_case', 'Production', model_name='my_model')
Show answer and explanation
Correct answer: C
Explanation
Tags for registered models in the Databricks Model Registry cannot be set using functions designed for active runs or nonexistent API methods. The correct method is to use the set_registered_model_tag function from the MlflowClient class, which allows you to specify the model name, tag key, and tag value.
- A. Incorrect.
This option is incorrect because
mlflow.set_tagsets tags for the currently active run, not for a registered model in the Model Registry. - B. Incorrect.
This option is incorrect because the
mlflow.register_model_tagfunction does not exist in the MLflow API. - C. Correct.
This option is correct because
MlflowClient().set_registered_model_tagis the correct method to set a tag on a registered model in the Databricks Model Registry. - D. Incorrect.
This option is incorrect because
MlflowClient().set_tagis not a valid function. The correct method for setting a tag on a registered model isset_registered_model_tag.