srowen commented on a change in pull request #24868: [SPARK-28044][ML][PYTHON] 
MulticlassClassificationEvaluator support more metrics
URL: https://github.com/apache/spark/pull/24868#discussion_r294343007
 
 

 ##########
 File path: 
mllib/src/main/scala/org/apache/spark/ml/evaluation/MulticlassClassificationEvaluator.scala
 ##########
 @@ -87,17 +120,30 @@ class MulticlassClassificationEvaluator @Since("1.5.0") 
(@Since("1.5.0") overrid
         case Row(prediction: Double, label: Double, weight: Double) => 
(prediction, label, weight)
       }
     val metrics = new MulticlassMetrics(predictionAndLabelsWithWeights)
-    val metric = $(metricName) match {
+    $(metricName) match {
       case "f1" => metrics.weightedFMeasure
+      case "accuracy" => metrics.accuracy
       case "weightedPrecision" => metrics.weightedPrecision
       case "weightedRecall" => metrics.weightedRecall
-      case "accuracy" => metrics.accuracy
+      case "weightedTruePositiveRate" => metrics.weightedTruePositiveRate
+      case "weightedFalsePositiveRate" => metrics.weightedFalsePositiveRate
+      case "weightedFMeasure" => metrics.weightedFMeasure($(beta))
+      case "truePositiveRateByLabel" => 
metrics.truePositiveRate($(metricLabel))
+      case "falsePositiveRateByLabel" => 
metrics.falsePositiveRate($(metricLabel))
+      case "precisionByLabel" => metrics.precision($(metricLabel))
+      case "recallByLabel" => metrics.recall($(metricLabel))
+      case "fMeasureByLabel" => metrics.fMeasure($(metricLabel), $(beta))
     }
-    metric
   }
 
   @Since("1.5.0")
-  override def isLargerBetter: Boolean = true
+  override def isLargerBetter: Boolean = {
+    $(metricName) match {
+      case "weightedFalsePositiveRate" => false
 
 Review comment:
   Nit: you can merge these two cases, not a big deal.

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