Github user manishamde commented on a diff in the pull request:
https://github.com/apache/spark/pull/1975#discussion_r16328124
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala ---
@@ -62,43 +62,38 @@ class DecisionTree (private val strategy: Strategy)
extends Serializable with Lo
timer.start("init")
val retaggedInput = input.retag(classOf[LabeledPoint])
+ val metadata = DTMetadata.buildMetadata(retaggedInput, strategy)
logDebug("algo = " + strategy.algo)
// Find the splits and the corresponding bins (interval between the
splits) using a sample
// of the input data.
timer.start("findSplitsBins")
- val (splits, bins) = DecisionTree.findSplitsBins(retaggedInput,
strategy)
+ val (splits, bins) = DecisionTree.findSplitsBins(retaggedInput,
metadata)
val numBins = bins(0).length
timer.stop("findSplitsBins")
logDebug("numBins = " + numBins)
+ // Bin feature values (TreePoint representation).
// Cache input RDD for speedup during multiple passes.
- val treeInput = TreePoint.convertToTreeRDD(retaggedInput, strategy,
bins)
+ val treeInput = TreePoint.convertToTreeRDD(retaggedInput, bins,
metadata)
.persist(StorageLevel.MEMORY_AND_DISK)
+ val numFeatures = metadata.numFeatures
// depth of the decision tree
val maxDepth = strategy.maxDepth
// the max number of nodes possible given the depth of the tree
- val maxNumNodes = math.pow(2, maxDepth + 1).toInt - 1
- // Initialize an array to hold filters applied to points for each node.
- val filters = new Array[List[Filter]](maxNumNodes)
- // The filter at the top node is an empty list.
- filters(0) = List()
+ val maxNumNodes = (2 << maxDepth) - 1
--- End diff --
May be a comment explaining this calculation will help. Even the previous
code might be a good comment. :-)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]