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

 ##########
 File path: 
mllib/src/main/scala/org/apache/spark/mllib/evaluation/MulticlassMetrics.scala
 ##########
 @@ -55,25 +55,40 @@ class MulticlassMetrics @Since("1.1.0") 
(predictionAndLabels: RDD[_ <: Product])
         throw new IllegalArgumentException(s"Expected Row of tuples, got 
$other")
     })
 
-  private lazy val labelCountByClass: Map[Double, Double] =
-    predLabelsWeight.map {
-      case (_: Double, label: Double, weight: Double) =>
+  private lazy val labelCountByClass: Map[Double, Double] = {
+    confusions.toSeq.map {
 
 Review comment:
   Because basically any method in this class requires computing `confusions`, 
I wonder if it's better to just compute `confusions` and the derived values 
here too immediately in the constructor and not retain `predLabelsWeight`. You 
can do that in one pass over `confusions` with some mutable Maps too, if perf 
is a concern

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

Reply via email to