def test_no_fp_at_50(self): y_true = np.array([1, 1, 1, 1, 1, 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]) fps = fp_at(y_true, y_score, proportion=0.5) self.assertEqual(fps, 0)
def test_some_fp_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]) fps = fp_at(y_true, y_score, proportion=1.0) self.assertEqual(fps, 6)
def test_with_nas(self): y_true = np.array([0, nan, 1, 1, 1, 1, 1, 1, 1, nan]) y_score = np.array([1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]) fps = fp_at(y_true, y_score, proportion=0.1) self.assertEqual(fps, 1)
def test_some_fp_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]) fps = fp_at(y_true, y_score, top_proportion=1.0) self.assertEqual(fps, 6)
def test_no_fp_at_50(self): y_true = np.array([1, 1, 1, 1, 1, 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]) fps = fp_at(y_true, y_score, top_proportion=0.5) self.assertEqual(fps, 0)
def test_with_nas(self): y_true = np.array([0, nan, 1, 1, 1, 1, 1, 1, 1, nan]) y_score = np.array([1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]) fps = fp_at(y_true, y_score, top_proportion=0.1) self.assertEqual(fps, 1)
def test_all_fp_at_10(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]) fps = fp_at(y_true, y_score, proportion=0.1) self.assertEqual(fps, 1)