-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
DOC Rework voting classifier example #30985
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
DOC Rework voting classifier example #30985
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.
Thanks for the PR. It's a nice improvement.
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Sorry for close, mis-click. Merged main so CI runs again and we can see the rendered docs. |
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.
Some nits, feel free to ignore.
No idea why the figure is not rendering properly in CI, maybe it's just me?
|
||
""" | ||
|
||
# Authors: The scikit-learn developers | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
from itertools import product | ||
# %% | ||
# We first generate a noisy XOR dataset, which is a binary classification task. |
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.
Is it worth adding that it is not linearly separable?
print(f"Predicted class of VotingClassifier: {eclf.predict(test_sample).ravel()}") | ||
|
||
# %% | ||
# Soft votes can be thresholded as for any other probabilistic classifier. |
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.
Maybe it would be nice to add a sentence about thresholding here, e.g.
This allows you to set a threshold probability at which the positive class will be predicted, instead of simply selecting the class with the highest predicted probability.
# To convert soft predictions into hard predictions when weights are provided, | ||
# the weighted average predicted probabilities are computed for each class. | ||
# Then, the final class label is then derived from the class label with the | ||
# highest average probability. |
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.
Maybe it would be nice to have the sentence:
"Which corresponds to the default threshold at 0.5 in the case of binary
classification."
here instead?
doc/modules/ensemble.rst
Outdated
.. figure:: ../auto_examples/ensemble/images/sphx_glr_plot_voting_decision_regions_001.png | ||
:target: ../auto_examples/ensemble/plot_voting_decision_regions.html |
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.
This doesn't seem to have rendered properly:
The voting regressor figure below is rendered fine, and it seems to have the same syntax ? 🤷
Also I think we don't want the first figure now, as that just shows the XOR dataset? i.e. ..plot_voting_decision_regions_001.png -> ..plot_voting_decision_regions_002.png ?
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 render is working now. The problem was the special marker ::
that was previously used to introduce a literal code block.
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.
Ah of course!
Co-authored-by: Lucy Liu <jliu176@gmail.com>
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, this is great and we get to remove a redundant example!
Co-authored-by: Lucy Liu <jliu176@gmail.com>
Thank you!! |
Reference Issues/PRs
Related to #27151.
What does this implement/fix? Explain your changes.
This PR reworks the Plot the decision boundaries of a VotingClassifier example, introducing a notebook style (see #22406).
The narrative is extended to better cover the use of weights, therefore making the Plot class probabilities calculated by the VotingClassifier example obsolete.
Any other comments?
Extrapolating seemed to me a more interesting use-case for
VotingClassifier
other than just using different model families.