Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-2197

Spark invoke DecisionTree by Java

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.1.0
    • MLlib
    • None

    Description

      Strategy strategy = new Strategy(Algo.Classification(), new Impurity() {
      @Override
      public double calculate(double arg0, double arg1, double arg2)

      { return Gini.calculate(arg0, arg1, arg2); }

      @Override
      public double calculate(double arg0, double arg1)

      { return Gini.calculate(arg0, arg1); }

      }, 5, 100, QuantileStrategy.Sort(), null, 256);
      DecisionTree decisionTree = new DecisionTree(strategy);
      final DecisionTreeModel decisionTreeModel = decisionTree.train(labeledPoints.rdd());

      i try to run it on spark, but find an error on the console:
      java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lorg.apache.spark.mllib.regression.LabeledPoint;
      at org.apache.spark.mllib.tree.DecisionTree$.findSplitsBins(DecisionTree.scala:990)
      at org.apache.spark.mllib.tree.DecisionTree.train(DecisionTree.scala:56)
      at org.project.modules.spark.java.SparkDecisionTree.main(SparkDecisionTree.java:75)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.apache.spark.deploy.SparkSubmit$.launch(SparkSubmit.scala:292)
      at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:55)
      at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

      i view source code, find
      val numFeatures = input.take(1)(0).features.size
      this is a problem.

      Attachments

        Issue Links

          Activity

            People

              josephkb Joseph K. Bradley
              onepiece wulin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: