In Spark ML, what is the difference between an estimator and a transformer?
- 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: Compare estimators and transformers
Comparing estimators and transformers is named.
Why A is the answer
Estimators fit() and return a model; transformers transform()
Estimators learn from data with fit() and produce a fitted model, which is itself a transformer. Transformers apply a mapping with transform().
Remember: Estimators fit; transformers transform.
How it works
Spark ML separates learning (fit) from applying (transform).
In detail
- Estimator.fit() returns a model.
- Transformer.transform() maps data.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Estimators fit() and return a model; transformers transform()Right
Estimators fit; transformers transform.
B. Estimators only work on images, while transformers only work on textWrong
Neither is limited by data type.
C. Transformers are trained with fit(); estimators only have transform()WrongMost tempting
That swaps them.
Why it tempts: The names are easy to swap.
D. There is no differenceWrong
They have different roles.
Use case
An illustrative scenario, not a real incident.
Illustrative: LogisticRegression is an estimator; its LogisticRegressionModel is a transformer.
See it in different ways
sequenceDiagram participant P0 as Training data participant P1 as Estimator participant P2 as Model P0->>P1: fit P1->>P2: fitted model P2-->>P0: transform adds predictions
How to read this chart
- 1. Training data sends "fit" to Estimator.
- 2. Estimator sends "fitted model" to Model.
- 3. Training data gets a reply from Model: "transform adds predictions".
mindmap
root(("Pipeline stages"))
n1["Estimators"]
n2["StringIndexer"]
n3["Imputer"]
n4["LogisticRegression"]
n5["Transformers"]
n6["VectorAssembler"]
n7["Fitted models"]How to read this chart
- The centre is "Pipeline stages".
- "Estimators" covers "StringIndexer", "Imputer", "LogisticRegression".
- "Transformers" covers "VectorAssembler", "Fitted models".