srowen commented on a change in pull request #21632: [SPARK-19591][ML][MLlib] 
Add sample weights to decision trees
URL: https://github.com/apache/spark/pull/21632#discussion_r243596211
 
 

 ##########
 File path: 
mllib/src/main/scala/org/apache/spark/ml/tree/impl/DecisionTreeMetadata.scala
 ##########
 @@ -115,7 +122,14 @@ private[spark] object DecisionTreeMetadata extends 
Logging {
     }
     require(numFeatures > 0, s"DecisionTree requires number of features > 0, " 
+
       s"but was given an empty features vector")
-    val numExamples = input.count()
+    val (numExamples, weightSum) = input.aggregate((0L, 0.0))(
+      (acc, x) => (acc, x) match {
 
 Review comment:
   I think the match statement is redundant? just `((count, weight), instance) 
=> ...`? I forget whether there's some scala reason that won't work but you're 
just providing a function with this arg anyway

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]

Reply via email to