Beispiel #1
0
    def test_param_stomping(self):
        testval_init = np.asarray([3, 2, 3, 0])
        testval = np.asarray([3, 2, 3, 0])

        x = ndcg.ndcg(testval, 4, False)
        self.assertEqual(testval_init.tolist(), testval.tolist())

        x = ndcg.idcg(testval, False)
        self.assertEqual(testval_init.tolist(), testval.tolist())

        x = ndcg.dcg(testval, False)
        self.assertEqual(testval_init.tolist(), testval.tolist())

        x = ndcg.cum_gain(testval)
        self.assertEqual(testval_init.tolist(), testval.tolist())
Beispiel #2
0
    def test_param_stomping(self):
        testval_init = np.asarray([3, 2, 3, 0])
        testval = np.asarray([3, 2, 3, 0])

        x = ndcg.ndcg(testval, 4, False)
        self.assertEqual(testval_init.tolist(), testval.tolist())

        x = ndcg.idcg(testval, False)
        self.assertEqual(testval_init.tolist(), testval.tolist())

        x = ndcg.dcg(testval, False)
        self.assertEqual(testval_init.tolist(), testval.tolist())

        x = ndcg.cum_gain(testval)
        self.assertEqual(testval_init.tolist(), testval.tolist())
Beispiel #3
0
 def test_cum_gain(self):
     # from wikipedia
     self.assertAlmostEqual(11.0, ndcg.cum_gain([3, 2, 3, 0, 1, 2]))
     # order is irrelevant
     self.assertAlmostEqual(11.0, ndcg.cum_gain([3, 1, 0, 3, 2, 2]))
Beispiel #4
0
 def test_cum_gain(self):
     # from wikipedia
     self.assertAlmostEqual(11.0, ndcg.cum_gain([3, 2, 3, 0, 1, 2]))
     # order is irrelevant
     self.assertAlmostEqual(11.0, ndcg.cum_gain([3, 1, 0, 3, 2, 2]))