Skip to content

Commit b7b2922

Browse files
committed
Fixed bug in python example decision_tree_runner.py with missing argument. Changed main DecisionTree aggregate to treeAggregate.
1 parent 85bbc1f commit b7b2922

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

examples/src/main/python/mllib/decision_tree_runner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def usage():
124124
(reindexedData, origToNewLabels) = reindexClassLabels(points)
125125

126126
# Train a classifier.
127-
model = DecisionTree.trainClassifier(reindexedData, numClasses=2)
127+
categoricalFeaturesInfo={} # no categorical features
128+
model = DecisionTree.trainClassifier(reindexedData, numClasses=2,
129+
categoricalFeaturesInfo=categoricalFeaturesInfo)
128130
# Print learned tree and stats.
129131
print "Trained DecisionTree for classification:"
130132
print " Model numNodes: %d\n" % model.numNodes()

mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import scala.collection.JavaConverters._
2222
import org.apache.spark.annotation.Experimental
2323
import org.apache.spark.api.java.JavaRDD
2424
import org.apache.spark.Logging
25+
import org.apache.spark.mllib.rdd.RDDFunctions._
2526
import org.apache.spark.mllib.regression.LabeledPoint
2627
import org.apache.spark.mllib.tree.configuration.Strategy
2728
import org.apache.spark.mllib.tree.configuration.Algo._
@@ -826,7 +827,7 @@ object DecisionTree extends Serializable with Logging {
826827
// Calculate bin aggregates.
827828
timer.start("aggregation")
828829
val binAggregates = {
829-
input.aggregate(Array.fill[Double](binAggregateLength)(0))(binSeqOp, binCombOp)
830+
input.treeAggregate(Array.fill[Double](binAggregateLength)(0))(binSeqOp, binCombOp)
830831
}
831832
timer.stop("aggregation")
832833
logDebug("binAggregates.length = " + binAggregates.length)

0 commit comments

Comments
 (0)