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_r287800833
 
 

 ##########
 File path: 
mllib/src/main/scala/org/apache/spark/mllib/evaluation/MultilabelMetrics.scala
 ##########
 @@ -179,3 +167,160 @@ class MultilabelMetrics @Since("1.2.0") 
(predictionAndLabels: RDD[(Array[Double]
   @Since("1.2.0")
   lazy val labels: Array[Double] = tpPerClass.keys.toArray.sorted
 }
+
+
+/**
+ * Trait for statistical summary for multi-label metrics.
+ */
+private[evaluation] trait MultilabelSummary {
+
+  def numDocs: Long
+
+  def numLabels: Long
+
+  def subsetAccuracy: Double
+
+  def accuracy: Double
+
+  def hammingLoss: Double
+
+  def precision: Double
+
+  def recall: Double
+
+  def f1Measure: Double
+
+  def tpPerClass: Map[Double, Long]
+
+  def fpPerClass: Map[Double, Long]
+
+  def fnPerClass: Map[Double, Long]
+}
+
+
+private[evaluation] class MultilabelSummarizer extends MultilabelSummary with 
Serializable {
+
+  private var docCnt = 0L
+  private val labelSet = mutable.Set.empty[Double]
+  private var subsetAccuracyCnt = 0L
+  private var accuracySum = 0.0
+  private var hammingLossSum = 0L
+  private var precisionSum = 0.0
+  private var recallSum = 0.0
+  private var f1MeasureSum = 0.0
+  private val tpPerClass_ = mutable.Map.empty[Double, Long]
 
 Review comment:
   Why the underscore?

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