Databricks Generative AI Engineer Associate Question 185
Select 3You are building a machine learning workflow in Databricks using a pyfunc model. The model requires input data to be scaled before inference and the prediction output to be converted into a human-readable format. Which of the following steps are necessary to implement this workflow using a pyfunc model with pre- and post-processing?
- A
Define a custom Python function that handles both pre-processing and post-processing in the pyfunc model's predict method.
- B
Use separate libraries for pre-processing and post-processing, and chain their outputs manually outside the pyfunc model.
- C
Package the pre-processing and post-processing logic together with the core model using MLflow pyfunc's custom model class.
- D
Use Databricks AutoML to automatically generate pre- and post-processing steps for the pyfunc model.
- E
Test the pyfunc model locally with sample data to validate the pre- and post-processing logic before deployment.
Show answer and explanation
Correct answers: A, C, E
Explanation
To implement a workflow using a pyfunc model with pre- and post-processing, you need to define a custom Python function for the predict method, package all logic into the pyfunc model using MLflow's custom model class, and test the model locally to validate its functionality. This approach ensures an efficient and cohesive deployment of the entire machine learning workflow.
- A. Correct.
Correct: A custom Python function in the pyfunc model's predict method allows you to handle both pre-processing and post-processing within the same model workflow, ensuring end-to-end functionality.
- B. Incorrect.
Incorrect: While this approach might work, it is not specific to the pyfunc model and does not leverage the built-in flexibility of the pyfunc model to encapsulate the entire workflow.
- C. Correct.
Correct: Packaging the pre- and post-processing logic with the core model using MLflow pyfunc's custom model class ensures that all steps are combined and managed as a single package.
- D. Incorrect.
Incorrect: Databricks AutoML does not automatically generate pre- and post-processing logic for a pyfunc model. Manual implementation is required.
- E. Correct.
Correct: Testing the pyfunc model locally ensures that the pre- and post-processing logic works as intended before deploying to production.