Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark 如何使用ApacheSparkML库对随机林执行网格搜索_Apache Spark_Apache Spark Mllib - Fatal编程技术网

Apache spark 如何使用ApacheSparkML库对随机林执行网格搜索

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

我想在ApacheSpark中的随机林模型上执行网格搜索。但我找不到这样的例子。有没有关于示例数据的示例,我可以使用网格搜索进行超参数调整

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方法中定义