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

    https://github.com/apache/spark/pull/13624#discussion_r68536810
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/tree/impl/GradientBoostedTrees.scala 
---
    @@ -205,31 +205,28 @@ private[spark] object GradientBoostedTrees extends 
Logging {
           case _ => data
         }
     
    -    val numIterations = trees.length
    -    val evaluationArray = Array.fill(numIterations)(0.0)
    -    val localTreeWeights = treeWeights
    -
    -    var predictionAndError = computeInitialPredictionAndError(
    -      remappedData, localTreeWeights(0), trees(0), loss)
    -
    -    evaluationArray(0) = predictionAndError.values.mean()
    -
         val broadcastTrees = sc.broadcast(trees)
    -    (1 until numIterations).foreach { nTree =>
    -      predictionAndError = 
remappedData.zip(predictionAndError).mapPartitions { iter =>
    -        val currentTree = broadcastTrees.value(nTree)
    -        val currentTreeWeight = localTreeWeights(nTree)
    -        iter.map { case (point, (pred, error)) =>
    -          val newPred = updatePrediction(point.features, pred, 
currentTree, currentTreeWeight)
    -          val newError = loss.computeError(newPred, point.label)
    -          (newPred, newError)
    -        }
    +    val localTreeWeights = treeWeights
    +    val treesIndices = trees.indices
    +
    +    val dataCount = remappedData.count()
    +    val evaluation = remappedData.map { point =>
    +      treesIndices.map { idx =>
    +        val prediction = broadcastTrees.value(idx)
    +          .rootNode
    +          .predictImpl(point.features)
    +          .prediction
    +        prediction * localTreeWeights(idx)
           }
    -      evaluationArray(nTree) = predictionAndError.values.mean()
    +      .scanLeft(0.0)(_ + _).drop(1)
    +      .map(prediction => loss.computeError(prediction, point.label))
         }
    -
    -    broadcastTrees.unpersist()
    -    evaluationArray
    +      .aggregate(treesIndices.map(_ => 0.0))(
    --- End diff --
    
    Ah, but this bit is inconsistent now since it's indented like the block 
above when it's in the parent block. Let's just keep it consistent one way or 
the other. The only style that I think would definitely not match the rest of 
the code is
    
    ```
        ... 
      }
        .map(...)
    ```


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