Example #1
0
 def test_some_tp_at_100(self):
     y_true = np.array([0, 0, 0, 0, 1, 0, 0, 1, 1, 1])
     y_score = np.array([1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1])
     tps = tp_at_percent(y_true, y_score, percent=1.0)
     self.assertEqual(tps, 4)
Example #2
0
 def test_no_tp_at_50(self):
     y_true = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
     y_score = np.array([1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1])
     tps = tp_at_percent(y_true, y_score, percent=0.5)
     self.assertEqual(tps, 0)
Example #3
0
 def test_all_tp_at_10(self):
     y_true = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
     y_score = np.array([1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1])
     tps = tp_at_percent(y_true, y_score, percent=0.1)
     self.assertEqual(tps, 1)
Example #4
0
 def test_some_tp_at_100(self):
     y_true = np.array([0, 0, 0, 0, 1, 0, 0, 1, 1, 1])
     y_score = np.array([1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1])
     tps = tp_at_percent(y_true, y_score, percent=1.0)
     self.assertEqual(tps, 4)
Example #5
0
 def test_no_tp_at_50(self):
     y_true = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
     y_score = np.array([1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1])
     tps = tp_at_percent(y_true, y_score, percent=0.5)
     self.assertEqual(tps, 0)
Example #6
0
 def test_all_tp_at_10(self):
     y_true = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
     y_score = np.array([1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1])
     tps = tp_at_percent(y_true, y_score, percent=0.1)
     self.assertEqual(tps, 1)