Github user WeichenXu123 commented on a diff in the pull request:
https://github.com/apache/spark/pull/18390#discussion_r156295173
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/evaluation/MulticlassClassificationEvaluator.scala
---
@@ -80,17 +102,42 @@ class MulticlassClassificationEvaluator
@Since("1.5.0") (@Since("1.5.0") overrid
case Row(prediction: Double, label: Double) => (prediction, label)
}
val metrics = new MulticlassMetrics(predictionAndLabels)
- val metric = $(metricName) match {
- case "f1" => metrics.weightedFMeasure
- case "weightedPrecision" => metrics.weightedPrecision
- case "weightedRecall" => metrics.weightedRecall
- case "accuracy" => metrics.accuracy
+ val metric = if (isSet(labelValue)) {
+ $(metricName) match {
+ case "f1" => metrics.fMeasure(getLabelValue)
+ case "precision" => metrics.precision(getLabelValue)
+ case "recall" => metrics.recall(getLabelValue)
+ case "tpr" => metrics.truePositiveRate(getLabelValue)
+ case "fpr" => metrics.falsePositiveRate(getLabelValue)
+ case weightedMetric
+ if
(MulticlassClassificationEvaluator.weightedOptions.contains(weightedMetric)) =>
+ throw new IllegalArgumentException(
+ s"metricName $weightedMetric cannot be specified when label
value is set.")
+ case _ => throw new IllegalArgumentException(
--- End diff --
I think this `case _` will never be reached. Code running into `case
weightedMetric`, if do not enter `if`, then will go out of match block. It
won't go to next 'case'.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]