Skip to content
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

train_test_split documentation: add example for stratify param #18735

Merged
merged 8 commits into from Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/modules/cross_validation.rst
Expand Up @@ -518,6 +518,8 @@ Here is a visualization of the cross-validation behavior. Note that
validation that allows a finer control on the number of iterations and
the proportion of samples on each side of the train / test split.

.. _stratification:

Cross-validation iterators with stratification based on class labels.
---------------------------------------------------------------------

Expand Down
5 changes: 2 additions & 3 deletions sklearn/model_selection/_split.py
Expand Up @@ -571,8 +571,6 @@ class StratifiedKFold(_BaseKFold):
stratified folds. The folds are made by preserving the percentage of
samples for each class.

Read more in the :ref:`User Guide <stratified_k_fold>`.

kirisakow marked this conversation as resolved.
Show resolved Hide resolved
Parameters
----------
n_splits : int, default=5
Expand Down Expand Up @@ -2119,7 +2117,8 @@ def train_test_split(*arrays,

stratify : array-like, default=None
If not None, data is split in a stratified fashion, using this as
the class labels.
the class labels.
kirisakow marked this conversation as resolved.
Show resolved Hide resolved
Read more about stratification in the :ref:`User Guide <stratification>`.

Returns
-------
Expand Down