Commit Graph

6 Commits

Author SHA1 Message Date
Dimitri Papadopoulos Orfanos d4d5f8c7e0
MAINT consistent use of `print(__doc__)` in examples (#21307)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
2021-10-22 15:33:22 +02:00
Thomas J. Fan 70a185ae59
MAINT Enable and run black on examples (#20502) 2021-10-07 10:13:00 +02:00
Rodion Martynov 0892a98fc9
Stratified Group KFold implementation (#18649)
* Initial implementation

* Forgot to add to second __add__ list

* Update split method parameter doc

* Added example; changed default test_size to 0.1; added to author list

* StratifiedGroupKFold impl and other improvements

* Add class to __all__ spec

* Remove random_state when no shuffle

* Tighter formatting

* Update the implementation of StratifiedGroupKFold

* Add StratifiedGroupKFold to __init__

* Add y checks to StartifiedGroupKFold

* Raise error if n_splits > max num samples in class

* Warn if n_splits > mn num samples in class

* Add SGKfold to general repr test

* Add SGKFold to 2d_y test case

* Add SGKfold to value erros test case

Parameters are the same as for StratifiedKFold
to ensure similar behavior given n_groups == n_samples

* Add SGKFold to StratifiedKFold test cases

The idea is to ensure similar behavior when groups are trivial
(n_groups == n_samples)

* Add SGKFold to reproducibility test case

* Add SGKFold to GroupKFold test case

* Add SGKFold to nested cv test case

* Add SGKFold to random_state with shuffle=False test case

* Add SGKFold to constant splits test case

* Fix repr test case

* Fix formatting issues

* Add samples to a fold with least num samples

Required to produce balanced size folds when the distribution of y is
more or less the same

* Remove GroupShuffleSplit impl

* Add notes to StratifiedGroupKFold

* Fix doctest

* Added stratified group kfold tests

* Better variable naming

* Add section to documentation

* Remove leftover StratifiedGroupShuffleSplit import

* Add changelist and reference to original kernel

* Better naming for least populated class check

* Better expression for number of labels

* Remove use of Counter

We already have this data in output of np.unique

* Add tests for homogeneous groups

* Add StratifiedGroupKFold test against GroupKFold

* Add changes to changelist in docstring

* Add StratifiedGroupKFold to classes.rst

* Fix description of StratifiedGroupKFold

* Move license notice out of docstring

* Disambiguate labels to classes in doc

* Add changelog entry

* Fix changelog author entry

* Fix StratifiedGroupKFold docstring

* Better variable names

* Remove defaultdict in favor of numpy indexing

* Extracted best_fold search into a separate method

* Make use of numpy broadcasting instead of for loop

* Encode groups and use arrays instead of dicts

* Use numpy sort instead of python

* Clarify shuffling behavior of StratifiedGroupKF in docs

* Switch name from label_idx to class_idx

* Remove accidentally leftover comment

* Fix np.sort keyword to support numpy < 1.15

* Fix typo in docstring

* Add StratifiedGroupKFold to visualization doc

* Add visualization for uneven group as an example

* Fix image numbers to match updated example

* Add author

* Add SGKF visualization to docs

* Add comments for groups in stratified CV tests

Co-authored-by: Leandro Hermida <hermidal@cs.umd.edu>
Co-authored-by: marrodion <rodion_martynov@epam.com>
2021-03-20 21:57:42 +11:00
Roman Yurchak 94f2e9c5d8
DOC simpler block delimitation in sphinx-gallery examples (#17068)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
2020-06-08 23:23:14 -04:00
Thomas J Fan 14f5302b70 DOC Link items explictly (#14817)
* DOC Link items explictly

* STY

* DOC Link another
2019-09-05 11:37:05 +02:00
Chris Holdgraf 1641f31cfa EXA Adding cv indices example (#11475) 2018-07-31 08:41:12 +08:00