A model needs features computed from the raw request at prediction time, such as text length and hour of day. How do you package that?
- Exam domain
- Model Development44% of the exam
- Difficulty
- Hard
- In this mock
- 22 questions on this domainPractise this domain
Why the exam asks this
Model Development (44% of the exam)
Objective in the exam guide: Create custom model objects using real-time feature engineering.
Custom model objects with real-time feature engineering are named.
Why B is the answer
A custom pyfunc PythonModel whose predict computes the features and then calls the model
A custom pyfunc model can transform raw inputs inside predict, so serving and training share one implementation.
Remember: Put request-time features in pyfunc predict.
How it works
pyfunc models carry pre- and post-processing.
In detail
- Feature logic inside predict.
- One artifact for training and serving.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Ask every client app to compute the features in exactly the same way before calling the endpointWrongMost tempting
Client-side logic drifts across apps.
Why it tempts: Client-side processing seems lightweight.
B. A custom pyfunc PythonModel whose predict computes the features and then calls the modelRight
Put request-time features in pyfunc predict.
C. A separate feature table refreshed nightlyWrong
Nightly tables miss request-time values.
D. A notebook that runs before each requestWrong
Notebooks are not in the request path.
Use case
An illustrative scenario, not a real incident.
Illustrative: a spam model computes link counts and hour of day inside predict.
See it in different ways
sequenceDiagram participant P0 as Client participant P1 as pyfunc model participant P2 as Inner model P0->>P1: raw request P1->>P2: computed features P2-->>P1: score P1-->>P0: prediction
How to read this chart
- 1. Client sends "raw request" to pyfunc model.
- 2. pyfunc model sends "computed features" to Inner model.
- 3. pyfunc model gets a reply from Inner model: "score".
- 4. Client gets a reply from pyfunc model: "prediction".
flowchart LR S0["Subclass PythonModel"] --> S1["load_context"] --> S2["predict with feature code"] --> S3["log_model"]
How to read this chart
- Read it in order: Subclass PythonModel, then load_context, then predict with feature code, then log_model.