-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
FIX sklearn.tree: fix validation of class_names argument for plot_tree #26903
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 @2maz! Nice simple change. Looks good, with one minor change in addition to what you've already done.
sklearn/tree/_export.py
Outdated
@@ -79,7 +79,7 @@ def __repr__(self): | |||
"decision_tree": [DecisionTreeClassifier, DecisionTreeRegressor], | |||
"max_depth": [Interval(Integral, 0, None, closed="left"), None], | |||
"feature_names": [list, None], | |||
"class_names": [list, None], | |||
"class_names": [list, None, "boolean"], |
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.
While we're here, we should probably also change list
to "array-like"
similarly to export_graphviz
. Also, totally just a nit-pick, but I like keeping None
as the final option by convention :)
"class_names": [list, None, "boolean"], | |
"class_names": ["array-like", "boolean", None], |
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 for the quick feedback. Just updated accordingly.
@2maz Just for future reference, please avoid force-pushing commits in these PRs. It's totally okay for now, but in general we pr
8000
efer to maintain the commit history within the branch/PR. When, eventually, we merge these into It helps for keeping history, debugging, and following development. Let me know if you have any questions/concerns regarding this. Thanks :) |
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 @2maz !
I think this is a bug fix and should be in 1.3.1. Please add an entry to the change log at |
True is the only available boolean option
…n#26903) Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
…n#26903) Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
…n#26903) Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Reference Issues/PRs
What does this implement/fix? Explain your changes.
In sklearn.tree.plot_tree: allow documented use of 'class_names' arguments, i.e. setting class_names=True
Currently this raises:
Replicate with:
Any other comments?
Reproducible with the above code snippet