Databricks Machine Learning Professional Question 37
Select 3You are training a machine learning model in Databricks and using MLflow to track experiments. As part of your workflow, you want to ensure the logged model's schema is accurately captured to avoid compatibility issues during deployment. Which of the following steps should you include in your MLflow experiment tracking workflow to log the model schema using model signatures and input examples?
- A
Log the model using
mlflow.pyfunc.log_model()and providesignatureandinput_examplearguments. - B
Use
mlflow.log_param()to log the model's schema and input examples manually. - C
Generate an example input DataFrame and pass it as the
input_exampleargument when logging the model. - D
Use
mlflow.log_metric()to capture the model's signature for schema tracking. - E
Use
mlflow.models.infer_signature()to infer the model's input and output schema from a sample input and output.
Show answer and explanation
Correct answers: A, C, E
Explanation
To effectively track a model's schema using MLflow, you need to log the model with a signature and input examples. The signature can be inferred using mlflow.models.infer_signature() from sample input and output data, and an input example should be provided when logging the model. This ensures schema compatibility during deployment. Using mlflow.pyfunc.log_model() with appropriate arguments is the recommended approach, while other methods like mlflow.log_param() or mlflow.log_metric() are not designed for schema tracking.
- A. Correct.
Correct.
mlflow.pyfunc.log_model()allows you to log a model with its signature and input examples. This is essential for ensuring the schema is properly captured. - B. Incorrect.
Incorrect.
mlflow.log_param()is used for tracking experiment parameters, not for logging model schema or input examples. - C. Correct.
Correct. Providing an example input DataFrame as the
input_exampleargument is a key step in logging the model's schema correctly. - D. Incorrect.
Incorrect.
mlflow.log_metric()is used for tracking performance metrics, not for schema or input example logging. - E. Correct.
Correct.
mlflow.models.infer_signature()is used to infer the input and output schema from a sample input and output, which is crucial for defining the model signature.