Why wrap indexing, encoding, assembling and the model into one Spark ML Pipeline?
- Exam domain
- Model Development31% of the exam
- Difficulty
- Medium
- In this mock
- 16 questions on this domainPractise this domain
Why the exam asks this
Model Development (31% of the exam)
Objective in the exam guide: Develop a training pipeline
Developing a training pipeline is named.
Why D is the answer
The same fitted steps run at training and scoring time
Pipeline.fit() fits every stage on training data and returns a PipelineModel that applies identical transformations at scoring time.
Remember: Pipelines keep training and scoring consistent.
How it works
Pipelines bundle preprocessing and model.
In detail
- One fit, one artifact.
- Same steps at scoring.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Pipelines remove the need for test dataWrong
Testing is still needed.
B. Pipelines are required to use Delta tablesWrong
Delta works without pipelines.
C. Pipelines run faster because they skip the fit step for every stageWrongMost tempting
Each estimator stage is still fitted.
Why it tempts: Convenience is mistaken for speed.
D. The same fitted steps run at training and scoring timeRight
Pipelines keep training and scoring consistent.
Use case
An illustrative scenario, not a real incident.
Illustrative: the PipelineModel is logged to MLflow, so scoring reuses the same encodings.
See it in different ways
flowchart LR S0["StringIndexer"] --> S1["OneHotEncoder"] --> S2["VectorAssembler"] --> S3["Classifier"] --> S4["PipelineModel"]
How to read this chart
- Read it in order: StringIndexer, then OneHotEncoder, then VectorAssembler, then Classifier, then PipelineModel.
sequenceDiagram participant P0 as Train data participant P1 as Pipeline participant P2 as PipelineModel P0->>P1: fit P1->>P2: all stages fitted P2-->>P0: transform test
How to read this chart
- 1. Train data sends "fit" to Pipeline.
- 2. Pipeline sends "all stages fitted" to PipelineModel.
- 3. Train data gets a reply from PipelineModel: "transform test".