diff options
author | wm624@hotmail.com <wm624@hotmail.com> | 2016-05-13 08:29:37 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-05-13 08:29:37 +0100 |
commit | bdff299f9e51b06b809fe505bda466009e759831 (patch) | |
tree | 9cbc4bede62660c76708474d1e1db1365c36fbac /mllib/src/test | |
parent | e1dc853737fc1739fbb5377ffe31fb2d89935b1f (diff) | |
download | spark-bdff299f9e51b06b809fe505bda466009e759831.tar.gz spark-bdff299f9e51b06b809fe505bda466009e759831.tar.bz2 spark-bdff299f9e51b06b809fe505bda466009e759831.zip |
[SPARK-14900][ML] spark.ml classification metrics should include accuracy
## What changes were proposed in this pull request?
(Please fill in changes proposed in this fix)
Add accuracy to MulticlassMetrics class and add corresponding code in MulticlassClassificationEvaluator.
## How was this patch tested?
(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
Scala Unit tests in ml.evaluation
Author: wm624@hotmail.com <wm624@hotmail.com>
Closes #12882 from wangmiao1981/accuracy.
Diffstat (limited to 'mllib/src/test')
-rw-r--r-- | mllib/src/test/scala/org/apache/spark/mllib/evaluation/MulticlassMetricsSuite.scala | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/mllib/src/test/scala/org/apache/spark/mllib/evaluation/MulticlassMetricsSuite.scala b/mllib/src/test/scala/org/apache/spark/mllib/evaluation/MulticlassMetricsSuite.scala index d55bc8c3ec..f316c67234 100644 --- a/mllib/src/test/scala/org/apache/spark/mllib/evaluation/MulticlassMetricsSuite.scala +++ b/mllib/src/test/scala/org/apache/spark/mllib/evaluation/MulticlassMetricsSuite.scala @@ -69,11 +69,12 @@ class MulticlassMetricsSuite extends SparkFunSuite with MLlibTestSparkContext { assert(math.abs(metrics.fMeasure(1.0, 2.0) - f2measure1) < delta) assert(math.abs(metrics.fMeasure(2.0, 2.0) - f2measure2) < delta) - assert(math.abs(metrics.recall - + assert(math.abs(metrics.accuracy - (2.0 + 3.0 + 1.0) / ((2 + 3 + 1) + (1 + 1 + 1))) < delta) - assert(math.abs(metrics.recall - metrics.precision) < delta) - assert(math.abs(metrics.recall - metrics.fMeasure) < delta) - assert(math.abs(metrics.recall - metrics.weightedRecall) < delta) + assert(math.abs(metrics.accuracy - metrics.precision) < delta) + assert(math.abs(metrics.accuracy - metrics.recall) < delta) + assert(math.abs(metrics.accuracy - metrics.fMeasure) < delta) + assert(math.abs(metrics.accuracy - metrics.weightedRecall) < delta) assert(math.abs(metrics.weightedFalsePositiveRate - ((4.0 / 9) * fpRate0 + (4.0 / 9) * fpRate1 + (1.0 / 9) * fpRate2)) < delta) assert(math.abs(metrics.weightedPrecision - |