【发布时间】:2020-10-18 23:31:07
【问题描述】:
我正在使用 PySpark 在 Spark MLlib 中使用随机森林算法进行分类。我的代码如下:\
model = RandomForest.trainClassifier(trnData, numClasses=3, categoricalFeaturesInfo={}, numTrees=3, featureSubsetStrategy="auto", impurity='gini', maxDepth=4, maxBins=32)
predictions = model.predict(tst_dataRDD.map(lambda x: x.features))
labelsAndPredictions = tst_dataRDD.map(lambda lp: lp.label).zip(predictions)
testErr = labelsAndPredictions.filter(lambda x: x[0] != x[1]).count() / float(tst_dataRDD.count())
我得到 IllegalArgumentException: GiniAggregator given label -0.0625 but requires label to be non-negative.
我怎么解决这个问题?谢谢
【问题讨论】:
-
完整的堆栈跟踪好吗?
标签: pyspark random-forest apache-spark-mllib illegalargumentexception