srowen commented on a change in pull request #27103: [SPARK-30381][ML] Refactor
GBT to reuse treePoints for all trees
URL: https://github.com/apache/spark/pull/27103#discussion_r363338006
##########
File path:
mllib/src/main/scala/org/apache/spark/ml/tree/impl/GradientBoostedTrees.scala
##########
@@ -111,14 +113,18 @@ private[spark] object GradientBoostedTrees extends
Logging {
* corresponding to every sample.
*/
def computeInitialPredictionAndError(
- data: RDD[Instance],
+ data: RDD[TreePoint],
initTreeWeight: Double,
initTree: DecisionTreeRegressionModel,
- loss: OldLoss): RDD[(Double, Double)] = {
- data.map { case Instance(label, _, features) =>
- val pred = updatePrediction(features, 0.0, initTree, initTreeWeight)
- val error = loss.computeError(pred, label)
- (pred, error)
+ loss: OldLoss,
+ bcSplits: Broadcast[Array[Array[Split]]]): RDD[(Double, Double)] = {
+ data.mapPartitions { iter =>
+ val splits = bcSplits.value
Review comment:
You don't really need mapPartitions for this. `.value` just returns a local
field always
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]