Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

qinhanmin2014
Copy link
Member

Part of #12312
Note to reviewer: _average_binary_score will raise an error at the beginning if y_true is not binary or multilabel-indicator so we don't need to raise an error in average_precision_score.

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a test for the len(present_labels) == 1 case then this lgtm

y_true = np.array([0, 1])
y_pred = np.array([0, 1])
erorr_message = ("pos_label=2 is invalid. Set it to a label in y_true.")
assert_raise_message(ValueError, erorr_message, average_precision_score,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erorr -> error (there's the same typo line 696)

@qinhanmin2014
Copy link
Member Author

If there is a test for the len(present_labels) == 1 case then this lgtm

@jnothman we have such a test

y_true = [1, 1]
y_score = [0.25, 0.75]
p, r, _ = precision_recall_curve(y_true, y_score)
assert_almost_equal(average_precision_score(y_true, y_score), 1.)
assert_array_almost_equal(p, [1., 1., 1.])
assert_array_almost_equal(r, [1, 0.5, 0.])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants