-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] Throw an error with explicit message if n_estimators is not an integer. #7457
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
Could you close this one and merge this commit onto your other PR (#7454). Both can be reviewed in one go... |
Couldn't figure out how to merge pull requests. I closed the old pull request. Since only whitespace characters were changed/deleted to comply with pep8 there is nothing lost by closing the first pull request, which does not have to be reviewed at all any more. |
While you are in this branch ( |
Ah, cool, thank you for teaching me how to 'cherry-pick'! There is nothing in the closed pull request that I want to migrate though. Everything that should be here from the other branch is already in this pull request. |
No problem at all. Thanks for the work! I didn't know you did that already... Now you will have to add the tests and ping us again. |
Now I understand how this works with the pull requests and latter pushing to the same branch which contains the pull request. It works even smoother than I imagined! |
Thanks for adding a test, but it fails on your branch because of a typo. |
Will it work if I amend the commit in the branch locally and push it 'again'? |
|
Just made a new commit. No forcing done. |
def test_base_not_int_n_estimators(): | ||
# Check that instantiating a BaseEnsemble with a string as n_estimators raises | ||
# a ValueError requesting n_estimators to be supplied as an integer. | ||
ensemble_string = BaggingClassifier(base_estimator=Perceptron(), n_estimators='3') |
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.
Can you
- check if this works for
np.int32(3)
- check if this raises an error for
3.0
I wonder, is there an easy way to build scikit-learn on Mac OS X? |
More info in the contributing guide. |
needs a rebase. |
Is there anything else that needs to be done before this PR can be merged? |
LGTM |
I wonder how the squash_and_merge GitHub function will deal with the rebase commit (d0666e4). |
|
||
def test_base_zero_n_estimators(): | ||
# Check that instantiating a BaseEnsemble with n_estimators<=0 raises | ||
# a ValueError. | ||
ensemble = BaggingClassifier(base_estimator=Perceptron(), n_estimators=0) | ||
ensemble = BaggingClassifier(base_estimator=Perceptron(), |
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.
why the newline?
@TomDLT rebase commit? I don't think there's such a thing... |
thanks! |
…n integer. (scikit-learn#7457) * Throw an error with explicit message if n_estimators is not an integer. * Testing for explicit message if n_estimators is not an integer. * Fixed typo in test for explicit message if n_estimators is an integer. * Added tests for np.int32 and float input. * pep8 compliance * fix function name * Import numpy to test n_estimators suplied as numpy int32.
…n integer. (scikit-learn#7457) * Throw an error with explicit message if n_estimators is not an integer. * Testing for explicit message if n_estimators is not an integer. * Fixed typo in test for explicit message if n_estimators is an integer. * Added tests for np.int32 and float input. * pep8 compliance * fix function name * Import numpy to test n_estimators suplied as numpy int32.
…n integer. (scikit-learn#7457) * Throw an error with explicit message if n_estimators is not an integer. * Testing for explicit message if n_estimators is not an integer. * Fixed typo in test for explicit message if n_estimators is an integer. * Added tests for np.int32 and float input. * pep8 compliance * fix function name * Import numpy to test n_estimators suplied as numpy int32.
…n integer. (scikit-learn#7457) * Throw an error with explicit message if n_estimators is not an integer. * Testing for explicit message if n_estimators is not an integer. * Fixed typo in test for explicit message if n_estimators is an integer. * Added tests for np.int32 and float input. * pep8 compliance * fix function name * Import numpy to test n_estimators suplied as numpy int32.
Reference Issue
Example: Fixes #7146
What does this implement/fix? Explain your changes.
Added type checking of n_estimators and made the corresponding error message explicit about the type issue.
I used the Type checking currently proposed in issue #7394
Any other comments?
I got the intended behavior when testing with rf.fit(n_estimators=100), which works as expeced, and rf.fit(n_estimators='100') which throws the type error as expected.
Example error message with traceback: