Skip to content

[MRG] Update default test_size of ShuffleSplit for 0.21 - #13483

Merged
jnothman merged 10 commits into
scikit-learn:masterfrom
jeremiedbb:split-train-test-size-default
Mar 25, 2019
Merged

jnothman merged 10 commits into
scikit-learn:masterfrom
jeremiedbb:split-train-test-size-default

Conversation

@jeremiedbb

Copy link
Copy Markdown
Member

Complement of #13443 in order to clean the deprecations for 0.21

I moved the _split part a this separate PR because the change is not straightforward and needs more work.

I've set test_size default value to None, which will be interpreted as the default value (depending on the estimator) when train_size is also None.

Comment thread sklearn/model_selection/_split.py Resolved
@jeremiedbb jeremiedbb changed the title [WIP] Update default test_size for 0.21 [WIP] Update default test_size of ShuffleSplit for 0.21 Mar 20, 2019
@jnothman

Copy link
Copy Markdown
Member

The not doing validation in __init__ is a convention for objects supporting set_params. CV splitters do not, so it doesn't apply here. But I'm not sure if it matters whether we validate then. Certainly can factor the code nicer.

@jeremiedbb jeremiedbb changed the title [WIP] Update default test_size of ShuffleSplit for 0.21 [MRG] Update default test_size of ShuffleSplit for 0.21 Mar 21, 2019

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks good but I think we need new tests in test_train_test_split to cover the new behavior when train_size is provided but test_size is left to it's default value.

    # simple test
    split = train_test_split(X, y, test_size=None, train_size=.5)
    X_train, X_test, y_train, y_test = split
    assert_equal(len(y_test), len(y_train))

should be changed to:

    # simple test
    split = train_test_split(X, y, train_size=.5)
    X_train, X_test, y_train, y_test = split
    assert_equal(len(y_test), len(y_train))

and probably something similar for ShuffleSplit / StratifiedShuffleSplit.

if train_size is not None and train_size_type not in ('i', 'f'):
raise ValueError("Invalid value for train_size: {}".format(train_size))
if test_size is not None and test_size_type not in ('i', 'f'):
raise ValueError("Invalid value for test_size: {}".format(test_size))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Technically it should be a TypeError but I guess it's too late to change now as it was already raising a ValueError for this case in released versions of scikit-learn.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah I guess so...

Comment thread sklearn/model_selection/_split.py Resolved

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I found another problem:

Comment thread sklearn/model_selection/_split.py Resolved
@jeremiedbb

Copy link
Copy Markdown
Member Author

I added tests for the new default value of test_size for all these classes/functions.

@ogrisel

ogrisel commented Mar 24, 2019 •

Copy link
Copy Markdown
Member

@jeremiedbb the circle ci status come from your account instead of scikit-learn's. Therefore I cannot restart those to check if the sphinx-gallery error can go away with a rebuild.

@jeremiedbb

Copy link
Copy Markdown
Member Author

I changed it and reran the CI.

@jnothman jnothman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @jeremiedbb!

@jnothman
jnothman merged commit 358c692 into scikit-learn:master Mar 25, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
@jeremiedbb
jeremiedbb deleted the split-train-test-size-default branch September 3, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants