def testAverageKeyedCorrelationMetric(self): m = metrics.AverageKeyedCorrelationMetric() m.Update('k1', [1.0, 2.0, 3.0], [0.1, 0.2, 0.3]) m.Update('k1', [1.0, 2.0, 3.0], [0.1, 0.2, 0.3]) m.Update('k2', [1.0, 2.0, 3.0], [0.3, 0.2, 0.1]) m.Update('k2', [1.0, 2.0, 3.0], [0.3, 0.2, 0.1]) self.assertEqual(0.0, m.value)
def testAverageKeyedCorrelationMetric(self): m = metrics.AverageKeyedCorrelationMetric() m.Update('k1', [1.0, 2.0, 3.0], [0.1, 0.2, 0.3]) m.Update('k2', [1.0, 2.0, 3.0], [0.1, 0.2, 0.3]) m.Update('k2', [1.0, 2.0, 3.0], [0.3, 0.2, 0.1]) # (1 / 1 + (1 + -1) / 2) / 2 self.assertAlmostEqual(0.5, m.value) m.Update('k3', [1.0], [0.3]) # k3 does not affect result self.assertAlmostEqual(0.5, m.value)
def testAverageKeyedCorrelationMetricEmptyInput(self): m = metrics.AverageKeyedCorrelationMetric() m.Update('k1', [], []) m.Update('k2', [], []) self.assertEqual(0.0, m.value)