Apache spark 如何使用ApacheSparkML库对随机林执行网格搜索
我想在ApacheSpark中的随机林模型上执行网格搜索。但我找不到这样的例子。有没有关于示例数据的示例,我可以使用网格搜索进行超参数调整Apache spark 如何使用ApacheSparkML库对随机林执行网格搜索,apache-spark,apache-spark-mllib,Apache Spark,Apache Spark Mllib,我想在ApacheSpark中的随机林模型上执行网格搜索。但我找不到这样的例子。有没有关于示例数据的示例,我可以使用网格搜索进行超参数调整 from pyspark.ml import Pipeline from pyspark.ml.classification import RandomForestClassifier from pyspark.ml.evaluation import BinaryClassificationEvaluator from pyspark.ml.tuning
from pyspark.ml import Pipeline
from pyspark.ml.classification import RandomForestClassifier
from pyspark.ml.evaluation import BinaryClassificationEvaluator
from pyspark.ml.tuning import CrossValidator, ParamGridBuilder
rf = RandomForestClassifier(labelCol="indexedLabel", featuresCol="indexedFeatures", numTrees=10)
pipeline = Pipeline(stages=[rf])
paramGrid = ParamGridBuilder().addGrid(rf.numTrees, [10, 30]).build()
crossval = CrossValidator(estimator=pipeline,
estimatorParamMaps=paramGrid,
evaluator=BinaryClassificationEvaluator(),
numFolds=2)
cvModel = crossval.fit(training_df)
超参数和网格在addGrid方法中定义