QuestionQ117

VerifiedCustom Model Serving

A machine learning engineer has created the following custom model class containing preprocessing logic that combines two columns:

Question Image

However, objects of this class cannot generate predictions.

Which set of changes will modify the class so that predictions can be computed while the preprocessing logic continues to be applied?

Explanation

The model is fitted using a transformed feature set that includes the derived price column. Prediction must apply the same transformation before calling the fitted random-forest model; otherwise, the inference features do not match those used for training. Calling self.preprocess_input(model_input.copy()) in predict supplies the required processed input.

Community Discussion

No comments yet. Be the first to start the discussion!