Which MLlib classes tune a Spark ML pipeline's regParam and elasticNetParam?
- 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: Tune a SparkML model using MLlib.
Tuning a Spark ML model with MLlib is named.
Why B is the answer
ParamGridBuilder with CrossValidator or TrainValidationSplit
MLlib tunes with ParamGridBuilder to build the grid and CrossValidator or TrainValidationSplit to evaluate each combination.
Remember: ParamGridBuilder plus a validator.
How it works
MLlib ships its own grid search and validation.
In detail
- ParamGridBuilder builds the grid.
- CrossValidator or TrainValidationSplit evaluates.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. VectorAssembler with a params argumentWrong
VectorAssembler builds vectors.
B. ParamGridBuilder with CrossValidator or TrainValidationSplitRight
ParamGridBuilder plus a validator.
C. StringIndexer with handleInvalidWrong
handleInvalid controls unseen labels.
D. Optuna's Spark backend, which is the only way to tune Spark ML models inside DatabricksWrongMost tempting
MLlib has its own tuning classes.
Why it tempts: Optuna works, but MLlib has native tuning.
Use case
An illustrative scenario, not a real incident.
Illustrative: a 3 × 3 grid over regParam and elasticNetParam is evaluated with 3-fold CV.
See it in different ways
flowchart LR S0["ParamGridBuilder"] --> S1["Evaluator"] --> S2["CrossValidator"] --> S3["fit"] --> S4["bestModel"]
How to read this chart
- Read it in order: ParamGridBuilder, then Evaluator, then CrossValidator, then fit, then bestModel.
mindmap
root(("MLlib tuning"))
n1["Grid"]
n2["ParamGridBuilder"]
n3["Validation"]
n4["CrossValidator"]
n5["TrainValidationSplit"]
n6["Scoring"]
n7["Evaluators"]How to read this chart
- The centre is "MLlib tuning".
- "Grid" covers "ParamGridBuilder".
- "Validation" covers "CrossValidator", "TrainValidationSplit".
- "Scoring" covers "Evaluators".