You need one forecasting model per store, 2,000 stores, trained in parallel. Which API fits?
- Exam domain
- Model Development44% of the exam
- Difficulty
- Medium
- 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: Use the Pandas Function API to parallelize group-specific model training and perform inference
Pandas Function API for group-specific training is named.
Why B is the answer
df.groupBy("store_id").applyInPandas(train_fn, schema)
applyInPandas runs a pandas function per group across executors, so each store's model trains in parallel.
Remember: applyInPandas for per-group models.
How it works
Grouped map pandas functions parallelize per-group work.
In detail
- groupBy plus applyInPandas.
- One model per group in parallel.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. CrossValidator with 2,000 foldsWrong
Folds are for validation.
B. df.groupBy("store_id").applyInPandas(train_fn, schema)Right
applyInPandas for per-group models.
C. A Python loop over stores on the driverWrongMost tempting
A driver loop is serial.
Why it tempts: Loops are the obvious first draft.
D. One global model with store_id as a feature onlyWrong
A global model is a different design.
Use case
An illustrative scenario, not a real incident.
Illustrative: 2,000 Prophet models train in 15 minutes and log to MLflow.
See it in different ways
sequenceDiagram participant P0 as Spark participant P1 as Executor participant P2 as train_fn P0->>P1: group for store 17 P1->>P2: pandas DataFrame P2-->>P1: model metadata row
How to read this chart
- 1. Spark sends "group for store 17" to Executor.
- 2. Executor sends "pandas DataFrame" to train_fn.
- 3. Executor gets a reply from train_fn: "model metadata row".
flowchart LR S0["groupBy store"] --> S1["applyInPandas"] --> S2["Log each model"] --> S3["Collect results"]
How to read this chart
- Read it in order: groupBy store, then applyInPandas, then Log each model, then Collect results.