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

Skip to content

DOC Typo in the error message of _binary_clf_curve #15703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sklearn/metrics/_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def _binary_clf_curve(y_true, y_score, pos_label=None, sample_weight=None):
classes_repr = ", ".join(repr(c) for c in classes)
raise ValueError("y_true takes value in {{{classes_repr}}} and "
"pos_label is not specified: either make y_true "
"take integer value in {{0, 1}} or {{-1, 1}} or "
"take value in {{0, 1}} or {{-1, 1}} or "
Copy link
Member

Choose a reason for hiding this comment

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

single brackets?

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry what do you mean?

Copy link
Member

Choose a reason for hiding this comment

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

{} instead of {{}}

Copy link
Member Author

Choose a reason for hiding this comment

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

@NicolasHug We can't use {} here because {} has special meaning. We need to use {{}} to output {}.

"pass pos_label explicitly.".format(
classes_repr=classes_repr))
elif pos_label is None:
Expand Down
4 changes: 2 additions & 2 deletions sklearn/metrics/tests/test_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def test_binary_clf_curve_implicit_pos_label(curve_func):
# Check that using string class labels raises an informative
# error for any supported string dtype:
msg = ("y_true takes value in {'a', 'b'} and pos_label is "
"not specified: either make y_true take integer "
"not specified: either make y_true take "
"value in {0, 1} or {-1, 1} or pass pos_label "
"explicitly.")
with pytest.raises(ValueError, match=msg):
Expand All @@ -695,7 +695,7 @@ def test_binary_clf_curve_implicit_pos_label(curve_func):
# The error message is slightly different for bytes-encoded
# class labels, but otherwise the behavior is the same:
msg = ("y_true takes value in {b'a', b'b'} and pos_label is "
"not specified: either make y_true take integer "
"not specified: either make y_true take "
"value in {0, 1} or {-1, 1} or pass pos_label "
"explicitly.")
with pytest.raises(ValueError, match=msg):
Expand Down