def tp_at(y_true, y_score, top_proportion): y_pred = binarize.scores_at_top_proportion(y_score, top_proportion) tp = (y_pred == 1) & (y_true == 1) return tp.sum()
def fn_at(y_true, y_score, top_proportion): y_pred = binarize.scores_at_top_proportion(y_score, top_proportion) fn = (y_pred == 0) & (y_true == 1) return fn.sum()
def fp_at(y_true, y_score, top_proportion): y_pred = binarize.scores_at_top_proportion(y_score, top_proportion) fp = (y_pred == 1) & (y_true == 0) return fp.sum()
def tn_at(y_true, y_score, top_proportion): y_pred = binarize.scores_at_top_proportion(y_score, top_proportion) tn = (y_pred == 0) & (y_true == 0) return tn.sum()
def test_at_100(self): binary_scores = binarize.scores_at_top_proportion(self.scores, 1.0) expected = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) np.testing.assert_equal(binary_scores, expected)