aboutsummaryrefslogtreecommitdiff
path: root/mllib/src/test
diff options
context:
space:
mode:
authorwm624@hotmail.com <wm624@hotmail.com>2016-05-13 08:29:37 +0100
committerSean Owen <sowen@cloudera.com>2016-05-13 08:29:37 +0100
commitbdff299f9e51b06b809fe505bda466009e759831 (patch)
tree9cbc4bede62660c76708474d1e1db1365c36fbac /mllib/src/test
parente1dc853737fc1739fbb5377ffe31fb2d89935b1f (diff)
downloadspark-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.scala9
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 -