Databricks Machine Learning Associate Question 484
Select 4You are managing a machine learning model registered in the Databricks Model Registry. You want to add a new tag to the model to specify the department responsible for maintaining it, and later remove the tag when no longer needed. Which of the following code snippets correctly implement these actions?
- A
mlflow.set_tag('department', 'finance')
- B
mlflow.delete_tag('department')
- C
mlflow.register_model_tag('department', 'finance')
- D
mlflow.log_model_tag('department', 'finance')
- E
from mlflow.tracking import MlflowClient; MlflowClient().set_registered_model_tag('model_name', 'department', 'finance')
- F
from mlflow.tracking import MlflowClient; MlflowClient().delete_registered_model_tag('model_name', 'department')
Show answer and explanation
Correct answers: A, B, E, F
Explanation
In Databricks, tags are useful for adding metadata to models. Tags can be applied to active runs or registered models in the Model Registry. The mlflow.set_tag() and mlflow.delete_tag() functions are used for managing tags on active runs, while the MlflowClient methods, like set_registered_model_tag() and delete_registered_model_tag(), are used for managing tags on registered models. Understanding when and how to use these functions is critical for managing metadata in a Databricks environment.
- A. Correct.
Correct. The
mlflow.set_tag()function is used to add a tag to the current active run, allowing metadata (like department) to be associated with a model. - B. Correct.
Correct. The
mlflow.delete_tag()function removes a tag from the current active run. - C. Incorrect.
Incorrect. The function
mlflow.register_model_tag()does not exist in MLflow's API. - D. Incorrect.
Incorrect. The function
mlflow.log_model_tag()does not exist in MLflow's API. - E. Correct.
Correct. The
MlflowClient().set_registered_model_tag()function is used to set a tag on a registered model in the Model Registry, specifying the model name, tag key, and tag value. - F. Correct.
Correct. The
MlflowClient().delete_registered_model_tag()function is used to remove a tag from a registered model in the Model Registry.