aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/metrics
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-02-15 08:26:14 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-02-15 08:30:00 -0800
commitc356d2800182ef7430a70baa2b1b75ea854f9adf (patch)
tree9c1de081bd6a01964967ed5e7fe39fb86e9d3593 /tensorflow/contrib/metrics
parentcf74c749aa9f7fb8eabb4a254c4f53cc2dbadae3 (diff)
Fix a bug of overestimating AUC_PR. When TP and FP are both 0s, the precision should be 0 instead of 1.
PiperOrigin-RevId: 185842713
Diffstat (limited to 'tensorflow/contrib/metrics')
-rw-r--r--tensorflow/contrib/metrics/python/ops/metric_ops_test.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/tensorflow/contrib/metrics/python/ops/metric_ops_test.py b/tensorflow/contrib/metrics/python/ops/metric_ops_test.py
index e067f08bab..b4e365d10f 100644
--- a/tensorflow/contrib/metrics/python/ops/metric_ops_test.py
+++ b/tensorflow/contrib/metrics/python/ops/metric_ops_test.py
@@ -1802,9 +1802,9 @@ class StreamingAUCTest(test.TestCase):
auc, update_op = metrics.streaming_auc(predictions, labels, curve='PR')
sess.run(variables.local_variables_initializer())
- self.assertAlmostEqual(0.79166, sess.run(update_op), delta=1e-3)
+ self.assertAlmostEqual(0.54166603, sess.run(update_op), delta=1e-3)
- self.assertAlmostEqual(0.79166, auc.eval(), delta=1e-3)
+ self.assertAlmostEqual(0.54166603, auc.eval(), delta=1e-3)
def testAnotherAUCPRSpecialCase(self):
with self.test_session() as sess:
@@ -1816,9 +1816,9 @@ class StreamingAUCTest(test.TestCase):
auc, update_op = metrics.streaming_auc(predictions, labels, curve='PR')
sess.run(variables.local_variables_initializer())
- self.assertAlmostEqual(0.610317, sess.run(update_op), delta=1e-3)
+ self.assertAlmostEqual(0.44365042, sess.run(update_op), delta=1e-3)
- self.assertAlmostEqual(0.610317, auc.eval(), delta=1e-3)
+ self.assertAlmostEqual(0.44365042, auc.eval(), delta=1e-3)
def testThirdAUCPRSpecialCase(self):
with self.test_session() as sess:
@@ -1830,9 +1830,9 @@ class StreamingAUCTest(test.TestCase):
auc, update_op = metrics.streaming_auc(predictions, labels, curve='PR')
sess.run(variables.local_variables_initializer())
- self.assertAlmostEqual(0.90277, sess.run(update_op), delta=1e-3)
+ self.assertAlmostEqual(0.73611039, sess.run(update_op), delta=1e-3)
- self.assertAlmostEqual(0.90277, auc.eval(), delta=1e-3)
+ self.assertAlmostEqual(0.73611039, auc.eval(), delta=1e-3)
def testAllIncorrect(self):
inputs = np.random.randint(0, 2, size=(100, 1))
@@ -1865,9 +1865,9 @@ class StreamingAUCTest(test.TestCase):
auc, update_op = metrics.streaming_auc(predictions, labels, curve='PR')
sess.run(variables.local_variables_initializer())
- self.assertAlmostEqual(1, sess.run(update_op), 6)
+ self.assertAlmostEqual(0.49999976, sess.run(update_op), 6)
- self.assertAlmostEqual(1, auc.eval(), 6)
+ self.assertAlmostEqual(0.49999976, auc.eval(), 6)
def testWithMultipleUpdates(self):
num_samples = 1000
@@ -6689,7 +6689,8 @@ class CohenKappaTest(test.TestCase):
# [[0, 25, 0],
# [0, 0, 25],
# [25, 0, 0]]
- # Calculated by v0.19: sklearn.metrics.cohen_kappa_score(labels, predictions)
+ # Calculated by v0.19: sklearn.metrics.cohen_kappa_score(
+ # labels, predictions)
expect = -0.333333333333
with self.test_session() as sess:
@@ -6748,7 +6749,8 @@ class CohenKappaTest(test.TestCase):
weights_t: weights[batch_start:batch_end]
})
# Calculated by v0.19: sklearn.metrics.cohen_kappa_score(
- # labels_np, predictions_np, sample_weight=weights_np)
+ # labels_np, predictions_np,
+ # sample_weight=weights_np)
expect = 0.289965397924
self.assertAlmostEqual(expect, kappa.eval(), 5)