How to Deploy Scikit-Learn Models on Vertex AI with Minimal Code?
You have recently trained a scikit-learn model that you plan to deploy on Vertex AI. This model will support both online and batch prediction. You need to preprocess input data for model inference. You want to package the model for deployment while minimizing additional code. What should you do?
Community Votes
100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
This question tests understanding of Vertex AI serving frameworks, where candidates often mistakenly prioritize prebuilt containers over CPR, overlooking that CPR natively supports custom inference logic with significantly reduced boilerplate.
Deploying machine learning models on Vertex AI requires selecting the right serving abstraction to balance customization and development overhead. Community consensus confirms that Custom Prediction Routines (CPR) provide the most efficient path for handling pre- and post-processing without writing a full HTTP server.
Candidates frequently select Option A, assuming prebuilt containers minimize effort, but they fail to recognize that prebuilt images cannot accommodate the required custom data preprocessing steps.
Community Discussion (7 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Custom Prediction Routines (CPR) are explicitly designed to simplify model serving by allowing developers to define custom Predictor classes that handle input parsing, preprocessing, model invocation, and output serialization. By leveraging the Vertex AI SDK, you can automatically generate the underlying container image, which eliminates the need to manually write Dockerfiles or configure HTTP servers. This approach directly satisfies the requirement to preprocess data while minimizing additional code.Why the Other Options Are Wrong
Option A relies on prebuilt containers, which offer zero flexibility for custom preprocessing or postprocessing logic. Options C and D involve building entirely custom containers from scratch, requiring manual setup of web servers, dependency management, and Docker configuration. These methods introduce significant boilerplate and maintenance overhead, contradicting the exam constraint to minimize additional code.Community Comment Notes
Multiple high-voted comments validate Option B, emphasizing that CPR abstracts away complex serving infrastructure while still supporting custom Python code [1][2]. Users note that while prebuilt containers seem simpler initially, they become impractical when preprocessing is mandatory [3]. The provided documentation links consistently point to Vertex AI official guidance, confirming CPR as the standard for lightweight custom serving [4].Official Reference
Exam Strategy
When Vertex AI questions mention preprocessing, postprocessing, or lightweight custom inference logic, immediately consider Custom Prediction Routines (CPR). Always weigh the minimize code constraint against the flexibility needed; if you do not need a completely new framework, CPR is almost always the exam preferred answer.
Related Analysis
Practice All PMLE Questions
Access 65 questions with complete answers and detailed explanations.
View Full PMLE Practice Test →