Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1975#discussion_r16322128
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala ---
    @@ -130,18 +129,35 @@ class DecisionTree (private val strategy: Strategy) 
extends Serializable with Lo
           // Find best split for all nodes at a level.
           timer.start("findBestSplits")
           val splitsStatsForLevel = DecisionTree.findBestSplits(treeInput, 
parentImpurities,
    -        strategy, level, filters, splits, bins, maxLevelForSingleGroup, 
timer)
    +        strategy, level, nodes, splits, bins, maxLevelForSingleGroup, 
unorderedFeatures, timer)
           timer.stop("findBestSplits")
     
    +      val levelNodeIndexOffset = math.pow(2, level).toInt - 1
           for ((nodeSplitStats, index) <- 
splitsStatsForLevel.view.zipWithIndex) {
    +        val nodeIndex = levelNodeIndexOffset + index
    +        val isLeftChild = level != 0 && nodeIndex % 2 == 1
    +        val parentNodeIndex = if (isLeftChild) { // -1 for root node
    --- End diff --
    
    minor: Is it cleaner if we offset node index by 1? So the root node has 
index 1 instead of 0, and then `parentNodeIndex = nodeIndex >> 1`.


---
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]

Reply via email to