imatiach-msft commented on a change in pull request #25926: [SPARK-9612][ML]
Add instance weight support for GBTs
URL: https://github.com/apache/spark/pull/25926#discussion_r335024820
##########
File path:
mllib/src/main/scala/org/apache/spark/ml/tree/impl/GradientBoostedTrees.scala
##########
@@ -197,41 +215,41 @@ private[spark] object GradientBoostedTrees extends
Logging {
* containing the first i+1 trees
*/
def evaluateEachIteration(
- data: RDD[LabeledPoint],
+ data: RDD[Instance],
trees: Array[DecisionTreeRegressionModel],
treeWeights: Array[Double],
loss: OldLoss,
algo: OldAlgo.Value): Array[Double] = {
val sc = data.sparkContext
val remappedData = algo match {
- case OldAlgo.Classification => data.map(x => new LabeledPoint((x.label *
2) - 1, x.features))
+ case OldAlgo.Classification =>
+ data.map(x => Instance((x.label * 2) - 1, x.weight, x.features))
case _ => data
}
val broadcastTrees = sc.broadcast(trees)
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)
+ val numTrees = trees.length
+
+ val (errSum, weightSum) = remappedData.mapPartitions { iter =>
Review comment:
sounds good
----------------------------------------------------------------
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]