所以我使用的代码如下:
DecisionTree.trainClassifier((org.apache.spark.api.java.JavaRDD<LabeledPoint>)dtTraining, numClasses.intValue(), (java.util.Map<Integer,Integer>) categoricalFeaturesInfo,
impurity, maxDepth.intValue(), maxBins.intValue());
但是有编译错误:
[ERROR] method org.apache.spark.mllib.tree.DecisionTree.trainClassifier(org.apache.spark.rdd.RDD<org.apache.spark.mllib.regression.LabeledPoint>,int,scala.collection.immutable.Map<java.lang.Object,java.lang.Object>,java.lang.String,int,int) is not applicable
[ERROR] (argument mismatch; org.apache.spark.api.java.JavaRDD<org.apache.spark.ml.feature.LabeledPoint> cannot be converted to org.apache.spark.rdd.RDD<org.apache.spark.mllib.regression.LabeledPoint>)
因此编译器没有在DecisionTree中看到有效的方法。
在我的pom.xml中,我有:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.11</artifactId>
<version>2.0.0</version>
<exclusions>
<exclusion>
<groupId>org.jpmml</groupId>
<artifactId>pmml-model</artifactId>
</exclusion>
</exclusions>
</dependency>
我正在研究DecisionTree使用的多个示例,似乎到处都是一切正常。可能有什么麻烦?
答案 0 :(得分:0)
发现我意外地导入了:
org.apache.spark.mllib.feature.LabeledPoint
而不是:
org.apache.spark.mllib.regression.LabeledPoint