-
-
Notifications
You must be signed in to change notification settings - Fork 26k
FIX Fix string formatting in the error message in CategoricalNB #16090
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @madhuracj !
This needs a test in sklearn/tests/test_naive_bayes.py at test_categoricalnb
. Something like this:
--- a/sklearn/tests/test_naive_bayes.py
+++ b/sklearn/tests/test_naive_bayes.py
@@ -667,6 +667,12 @@ def test_categoricalnb():
assert_raise_message(ValueError, error_msg, clf.predict, X)
assert_raise_message(ValueError, error_msg, clf.fit, X, y)
+ # Check error is failed for incorrect X
+ X = np.array([[1, 4, 1], [2, 5, 6]])
+ msg = "Expected input with 2 features, got 3 instead"
+ with pytest.raises(ValueError, match=msg):
+ clf.predict(X)
+
# Test alpha
X3_test = np.array([[2, 5]])
# alpha=1 increases the count of all categories by one so the final
Thanks @thomasjpfan, I've updated the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Please add an entry to the change log at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @madhuracj.
Not sure this needs a what's new entry @thomasjpfan? this isn't a bugfix
It may not be a numerical bug. I can see this as a user interface bug of "not showing the correct error message". I am okay with not having a whats new for this. |
@thomasjpfan Changelog entry added in ba48799 in case you want to include one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whats new is in alphabetic order by the module name. In this case sklearn.naive_bayes
is after the sklearn.model_selection
section.
Reference Issues/PRs
What does this implement/fix? Explain your changes.
This is a simple fix, correcting the string formatting in the error message.
Any other comments?