我正在尝试使用java和apache spark 1.0.0版本为决策树分类器实现简单的演示.我的基础是http://spark.apache.org/docs/1.0.0/mllib-decision-tree.html.到目前为止,我已经编写了下面列出的代码.
符合以下代码我得到错误:
org.apache.spark.mllib.tree.impurity.Impurity impurity = new org.apache.spark.mllib.tree.impurity.Entropy();
Run Code Online (Sandbox Code Playgroud)
类型不匹配:无法从Entropy转换为Impurity.这对我来说很奇怪,而类Entropy实现了Impurity接口:
https://spark.apache.org/docs/1.0.0/api/java/org/apache/spark/mllib/tree/impurity/Entropy.html
我正在寻找问题的答案为什么我不能做这个任务?
package decisionTree;
import java.util.regex.Pattern;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.mllib.linalg.Vectors;
import org.apache.spark.mllib.regression.LabeledPoint;
import org.apache.spark.mllib.tree.DecisionTree;
import org.apache.spark.mllib.tree.configuration.Algo;
import org.apache.spark.mllib.tree.configuration.Strategy;
import org.apache.spark.mllib.tree.impurity.Gini;
import org.apache.spark.mllib.tree.impurity.Impurity;
import scala.Enumeration.Value;
public final class DecisionTreeDemo {
static class ParsePoint implements Function<String, LabeledPoint> {
private static final Pattern COMMA = Pattern.compile(",");
private static final Pattern SPACE = Pattern.compile(" ");
@Override
public LabeledPoint call(String line) {
String[] parts = COMMA.split(line);
double y = …Run Code Online (Sandbox Code Playgroud) 我正在寻找具有良好osgi支持的java orm.我已经阅读过hibernate但是在类加载时会出现一些问题.