Databricks Machine Learning Professional Question 39
Select 3You are building a machine learning model to predict house prices and are using MLflow to track your experiments. To ensure the model's inputs and outputs are well-documented for easier deployment and validation, you decide to use model signatures and input examples. Which of the following steps should you take to correctly log the model with this information?
- A
Use the MLflow
log_modelfunction and specify a model signature generated from a sample input DataFrame. - B
Generate an input example DataFrame that represents typical input data and pass it to the MLflow
log_modelfunction. - C
Ensure the model signature is automatically inferred during model training and skip explicitly defining it.
- D
Add the input example to the
log_modelfunction to guide downstream consumers on the expected input format. - E
Log the model signature separately using the MLflow
log_metricsfunction.
Show answer and explanation
Correct answers: A, B, D
Explanation
When tracking experiments and logging models in MLflow, it is crucial to document the model's input and output schema using model signatures and provide input examples. This ensures that the model is well-documented, enabling easier validation, reproducibility, and deployment. The log_model function allows you to include both the model signature and input examples, making it the appropriate approach.
- A. Correct.
Correct: Using the
log_modelfunction with a model signature created from a sample input DataFrame ensures that the model's input and output schema is captured, which is critical for deployment. - B. Correct.
Correct: Providing an input example helps document the expected input format and allows downstream users to understand the typical structure of the data.
- C. Incorrect.
Incorrect: While MLflow can infer a signature in some cases, explicitly defining it ensures accuracy and avoids potential mismatches during deployment.
- D. Correct.
Correct: Including the input example directly in the
log_modelfunction is a best practice to guide users on the expected input format and schema. - E. Incorrect.
Incorrect: Model signatures cannot be logged using the
log_metricsfunction. Metrics are numerical performance indicators and are not related to the schema of the model.