Databricks Machine Learning Professional Question 38
Select 3You are building a machine learning model with Databricks and want to ensure the model's inputs and outputs are well-documented for future use. You decide to use MLflow to log the model with a signature and an input example. Which of the following steps are necessary to achieve this?
- A
Use the
mlflow.models.signature.infer_signaturefunction to capture the model's input and output schema. - B
Provide a sample input DataFrame when calling
mlflow.log_modelto log the input example. - C
Manually define the input schema by writing a JSON file and upload it as a model artifact.
- D
Call
mlflow.log_modelwith thesignatureandinput_exampleparameters. - E
Use the
mlflow.create_signaturefunction to create a signature object before logging the model.
Show answer and explanation
Correct answers: A, B, D
Explanation
To effectively use MLflow for experiment tracking and ensure the model's input and output schemas are captured, you need to use the mlflow.models.signature.infer_signature function to infer the schema, provide a valid input example, and log both using the mlflow.log_model function. This ensures transparency and reproducibility for your machine learning workflows.
- A. Correct.
Correct. The
mlflow.models.signature.infer_signaturefunction is used to automatically infer the schema of the model's inputs and outputs from a DataFrame or array, which is essential for creating the model signature. - B. Correct.
Correct. Providing a sample input DataFrame as the
input_exampleparameter helps document the expected input structure for the model, making it easier to reuse or validate later. - C. Incorrect.
Incorrect. While it is possible to define a schema manually, MLflow provides functionality to infer the schema and log it automatically, making manual efforts unnecessary.
- D. Correct.
Correct. The
mlflow.log_modelfunction allows you to attach the inferred signature and an input example to the logged model, ensuring the inputs and outputs are well-documented. - E. Incorrect.
Incorrect. There is no
mlflow.create_signaturefunction in MLflow. The correct approach is to usemlflow.models.signature.infer_signature.