def test_no_labels_at_50(self): y_true = np.array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan]) y_score = np.random.rand(1, 10) labels = labels_at_percent(y_true, y_score, percent=0.5, normalize=False) self.assertEqual(labels, 0)
def test_60_labels_at_60_mixed_values(self): y_true = np.array([1, 0, 0, 1, 0, 1, nan, nan, nan, 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]) labels = labels_at_percent(y_true, y_score, percent=0.6, normalize=False) self.assertEqual(labels, 6)
def test_60_labels_at_30_norm(self): y_true = np.array([1, 1, 1, 1, 1, 1, nan, nan, nan, 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]) labels = labels_at_percent(y_true, y_score, percent=0.3, normalize=True) self.assertEqual(labels, 0.5)
def test_one_label_at_100(self): y_true = np.array([1, nan, nan, nan, nan, nan, nan, nan, nan, 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]) labels = labels_at_percent(y_true, y_score, percent=1.0, normalize=False) self.assertEqual(labels, 1)
def test_one_label_at_10(self): y_true = np.array([1, nan, nan, nan, nan, nan, nan, nan, nan, 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]) labels = labels_at_percent(y_true, y_score, percent=0.1, normalize=False) self.assertEqual(labels, 1)
def test_no_labels_at_100(self): y_true = np.array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan]) y_score = np.random.rand(1, 10) labels = labels_at_percent(y_true, y_score, percent=1.0, normalize=False) self.assertEqual(labels, 0)