ParamGridBuilder¶
- 
class pyspark.ml.tuning.ParamGridBuilder[source]¶
- Builder for a param grid used in grid search-based model selection. - New in version 1.4.0. - Examples - >>> from pyspark.ml.classification import LogisticRegression >>> lr = LogisticRegression() >>> output = ParamGridBuilder() \ ... .baseOn({lr.labelCol: 'l'}) \ ... .baseOn([lr.predictionCol, 'p']) \ ... .addGrid(lr.regParam, [1.0, 2.0]) \ ... .addGrid(lr.maxIter, [1, 5]) \ ... .build() >>> expected = [ ... {lr.regParam: 1.0, lr.maxIter: 1, lr.labelCol: 'l', lr.predictionCol: 'p'}, ... {lr.regParam: 2.0, lr.maxIter: 1, lr.labelCol: 'l', lr.predictionCol: 'p'}, ... {lr.regParam: 1.0, lr.maxIter: 5, lr.labelCol: 'l', lr.predictionCol: 'p'}, ... {lr.regParam: 2.0, lr.maxIter: 5, lr.labelCol: 'l', lr.predictionCol: 'p'}] >>> len(output) == len(expected) True >>> all([m in expected for m in output]) True - Methods - addGrid(param, values)- Sets the given parameters in this grid to fixed values. - baseOn(*args)- Sets the given parameters in this grid to fixed values. - build()- Builds and returns all combinations of parameters specified by the param grid. - Methods Documentation - 
addGrid(param: pyspark.ml.param.Param[Any], values: List[Any]) → pyspark.ml.tuning.ParamGridBuilder[source]¶
- Sets the given parameters in this grid to fixed values. - param must be an instance of Param associated with an instance of Params (such as Estimator or Transformer). - New in version 1.4.0. 
 - 
baseOn(*args: Union[ParamMap, Tuple[pyspark.ml.param.Param, Any]]) → ParamGridBuilder[source]¶
- Sets the given parameters in this grid to fixed values. Accepts either a parameter dictionary or a list of (parameter, value) pairs. - New in version 1.4.0. 
 
-