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

    https://github.com/apache/spark/pull/1975#discussion_r16322135
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala ---
    @@ -818,36 +760,25 @@ object DecisionTree extends Serializable with Logging 
{
          *
          * @param agg Array storing aggregate calculation, updated by this 
function.
          *            Size: 3 * numBins * numFeatures * numNodes
    -     * @param arr Bin mapping from findBinsForLevel.
    -     *             Array of size 1 + (numFeatures * numNodes).
    +     * @param treePoint   Data point being aggregated.
    +     * @param nodeIndex  Node corresponding to treePoint. Indexed from 0 
at start of (level, group).
          * @return agg
          */
    -    def regressionBinSeqOp(arr: Array[Double], agg: Array[Double]): Unit = 
{
    -      // Iterate over all nodes.
    -      var nodeIndex = 0
    -      while (nodeIndex < numNodes) {
    -        // Check whether the instance was valid for this nodeIndex.
    -        val validSignalIndex = 1 + numFeatures * nodeIndex
    -        val isSampleValidForNode = arr(validSignalIndex) != InvalidBinIndex
    -        if (isSampleValidForNode) {
    -          // actual class label
    -          val label = arr(0)
    -          // Iterate over all features.
    -          var featureIndex = 0
    -          while (featureIndex < numFeatures) {
    -            // Find the bin index for this feature.
    -            val arrShift = 1 + numFeatures * nodeIndex
    -            val arrIndex = arrShift + featureIndex
    -            // Update count, sum, and sum^2 for one bin.
    -            val aggShift = 3 * numBins * numFeatures * nodeIndex
    -            val aggIndex = aggShift + 3 * featureIndex * numBins + 
arr(arrIndex).toInt * 3
    -            agg(aggIndex) = agg(aggIndex) + 1
    -            agg(aggIndex + 1) = agg(aggIndex + 1) + label
    -            agg(aggIndex + 2) = agg(aggIndex + 2) + label * label
    -            featureIndex += 1
    -          }
    -        }
    -        nodeIndex += 1
    +    def regressionBinSeqOp(agg: Array[Double], treePoint: TreePoint, 
nodeIndex: Int): Unit = {
    +      val label = treePoint.label
    +      // Iterate over all features.
    +      var featureIndex = 0
    +      while (featureIndex < numFeatures) {
    +        // Update count, sum, and sum^2 for one bin.
    +        val binIndex = treePoint.binnedFeatures(featureIndex)
    +        val aggIndex =
    +          3 * numBins * numFeatures * nodeIndex +
    +          3 * numBins * featureIndex +
    +          3 * binIndex
    +        agg(aggIndex) = agg(aggIndex) + 1
    --- End diff --
    
    use `agg(aggIndex) += 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