How to deploy XGBoost with preprocessing on Vertex AI?

You recently trained a XGBoost model that you plan to deploy to production for online inference. Before sending a predict request to your model’s binary, you need to perform a simple data preprocessing step. This step exposes a REST API that accepts requests in your internal VPC Service Controls and returns predictions. You want to configure this preprocessing step while minimizing cost and effort. What should you do?

  1. Store a pickled model in Cloud Storage. Build a Flask-based app, package the app in a custom container image, and deploy the model to Vertex AI Endpoints.
  2. Build a Flask-based app, package the app and a pickled model in a custom container image, and deploy the model to Vertex AI Endpoints.
  3. Build a custom predictor class based on XGBoost Predictor from the Vertex AI SDK, package it and a pickled model in a custom container image based on a Vertex built-in image, and deploy the model to Vertex AI Endpoints.
  4. Build a custom predictor class based on XGBoost Predictor from the Vertex AI SDK, and package the handler in a custom container image based on a Vertex built-in container image. Store a pickled model in Cloud Storage, and deploy the model to Vertex AI Endpoints. Source Reference Answer

Community Votes

D
71%
B
29%

71% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

The exam tests the ability to decouple model artifacts from container code using Vertex AI's custom predictor pattern, where the common trap is bundling the model inside the container image which increases size and deployment complexity.

To deploy an XGBoost model with a preprocessing step while minimizing cost and effort, you should use a custom predictor class based on the Vertex AI SDK's XGBoost Predictor. The community consensus is to store the model artifact in Cloud Storage and use a Vertex built-in container image for the handler to optimize deployment and updates.

Choosing Option C or B because they seem straightforward, but they incorrectly package the model inside the container, leading to larger images and the need to rebuild containers for every model update.

Community Discussion (4 comments)

lunalongo 👍 2 Selected: B
Option B is simpler (Flask app handles preproc directly) and less costly (Storage within the container)
fitri001 👍 3 Selected: D
why not c? While it utilizes the XGBoost Predictor, packaging the pickled model in the container increases image size and requires redeploying the container for model updates.
guilhermebutzke 👍 1 Selected: D
My Answer: D This option involves using the Vertex AI SDK to build a custom predictor class, which allows for easy integration with the XGBoost model. Packaging the handler in a custom container image based on a Vertex built-in container image ensures compatibility and smooth deployment. Storing the pickled model in Cloud Storage provides a scalable and reliable way to access the model. Deploying the model to Vertex AI Endpoints allows for easy management and scaling of inference requests, while minimizing cost and effort. The main difference between C and D is where the model is saved. So, is a good practice to save models in GCS because Separation of Concerns, Flexibility, and Reduced Image Size
pikachu007 👍 1 Selected: D
Minimal Custom Code: Leverages the pre-built XGBoost Predictor class for core model prediction, reducing development effort and potential errors. Optimized Container Image: Utilizes a Vertex built-in container image, pre-configured for efficient model serving and compatibility with Vertex AI Endpoints. Separated Model Storage: Stores the model in Cloud Storage, reducing container image size and simplifying model updates independently of the container. VPC Service Controls: Vertex AI Endpoints support VPC Service Controls, ensuring adherence to internal traffic restrictions.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

Option D is the correct choice because it leverages the Vertex AI SDK to create a custom predictor class, which handles the specific preprocessing logic required by the scenario. By storing the pickled model in Cloud Storage and using a container based on a Vertex built-in image, you minimize the container size and reduce the effort needed for updates. This architecture allows you to update the model by simply replacing the file in Cloud Storage without rebuilding or redeploying the container image.

Why the Other Options Are Wrong

Options A and B suggest building a Flask-based app, which requires more development effort than using the pre-built predictor classes provided by the Vertex AI SDK. Options B and C are incorrect because they package the pickled model directly into the container image. This increases the image size and necessitates a full container rebuild and redeployment whenever the model is retrained, which contradicts the requirement to minimize effort.

Community Comment Notes

The community strongly supports Option D (71 votes), highlighting that separating the model storage from the container prevents the need for redeploying the container for model updates (Comment 1). Commenters also noted that utilizing the Vertex built-in container image ensures compatibility and reduces the amount of custom code required, optimizing for both cost and development time (Comment 4).

Official Reference

Exam Strategy

When deploying models on Vertex AI, always prefer storing model artifacts in Cloud Storage rather than baking them into the container image to facilitate faster iterations and reduce deployment overhead.

Related Analysis

Practice All PMLE Questions

Access 65 questions with complete answers and detailed explanations.

View Full PMLE Practice Test →

← Back to PMLE Study Guide