You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/05/28 02:36:16 UTC

[GitHub] [spark] zhengruifeng commented on a change in pull request #24717: [SPARK-27847][ML] One-Pass MultilabelMetrics & MulticlassMetrics

zhengruifeng commented on a change in pull request #24717: [SPARK-27847][ML] One-Pass MultilabelMetrics & MulticlassMetrics
URL: https://github.com/apache/spark/pull/24717#discussion_r287912065
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/mllib/evaluation/MultilabelMetrics.scala
 ##########
 @@ -38,76 +40,62 @@ class MultilabelMetrics @Since("1.2.0") (predictionAndLabels: RDD[(Array[Double]
       (r.getSeq[Double](0).toArray, r.getSeq[Double](1).toArray)
     })
 
-  private lazy val numDocs: Long = predictionAndLabels.count()
+  /**
+   * Use MultilabelSummarizer to calculate all summary statistics of predictions
+   * and labels on one pass.
+   */
+  private lazy val summary: MultilabelSummary = {
+    predictionAndLabels
+      .treeAggregate(new MultilabelSummarizer)(
+        (summary, sample) => summary.add(sample._1, sample._2),
 
 Review comment:
   If I convert this to `(summary, (preds, l)) => summary.add(preds, l),` then the IDEA complains 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org