1.1 Using Spark ML
1.Which component is used in Spark ML to define a grid of hyperparameters and construct all the possible combinations to be used by `CrossValidator` or `TrainValidationSplit`?
- A.`GridSearcher`
- B.`HyperparameterBuilder`
- C.`ParamGridBuilder`
- D.`EstimatorParamMap`
Show answer & explanation
Correct answer: C — `ParamGridBuilder`
- A. Incorrect. `GridSearcher` is not a valid component in the Spark ML library. While the process is called 'grid search,' this specific class name does not exist.
- B. Incorrect. `HyperparameterBuilder` is a plausible but non-existent class in Spark ML. The library uses a different naming convention for its tuning utilities.
- C. Correct. `ParamGridBuilder` from the `pyspark.ml.tuning` module is the utility class specifically designed to construct a grid of parameters. It provides methods like `.addGrid()` to specify hyperparameters and their potential values, and its `.build()` method creates the full list of parameter combinations that are then used by `CrossValidator` or `TrainValidationSplit` for model tuning.
- D. Incorrect. An `EstimatorParamMap` represents a single set of parameters for an Estimator. While `ParamGridBuilder` generates a list of `EstimatorParamMap` objects, it is the builder itself, not the map, that is used to define and construct the entire grid.