Databricks Machine Learning Associate Question 486
Single answerYou are working on a machine learning project in Databricks and want to organize your registered models by adding metadata. Specifically, you want to add a 'stage' tag with the value 'production' to a model version. Which of the following code snippets will correctly set this tag?
- A
mlflow.set_model_tag('stage', 'production')
- B
mlflow.set_tag('stage', 'production')
- C
mlflow.register_model_tag('model_name', 'stage', 'production')
- D
mlflow.tracking.MlflowClient().set_model_version_tag('model_name', '1', 'stage', 'production')
Show answer and explanation
Correct answer: D
Explanation
To set or modify a tag for a specific registered model version in Databricks, you need to use the set_model_version_tag method from the MLflow Client API. This method requires the model name, version number, tag name, and tag value as inputs. The other options provided either refer to non-existent methods or are used for setting tags in different contexts (such as runs).
- A. Incorrect.
This option is incorrect because 'mlflow.set_model_tag' is not a valid function in the MLflow library.
- B. Incorrect.
This option is incorrect because 'mlflow.set_tag' is used to set tags on runs, not on models.
- C. Incorrect.
This option is incorrect because 'mlflow.register_model_tag' is not a valid function in the MLflow library.
- D. Correct.
This option is correct because 'mlflow.tracking.MlflowClient().set_model_version_tag' is the correct function to set a tag on a specific model version. You need to specify the model name, version, key (tag name), and value.