Commit Graph

49 Commits

Author SHA1 Message Date
Roman Yurchak acb8106472 MNT Use list and dict comprehension (#12668) 2019-01-08 09:32:34 +11:00
Hanmin Qin 6dd6af78eb TST Use match instead of message in pytest.raises (#12933) 2019-01-07 15:20:11 +01:00
Andreas Mueller 952ef6637a MRG Drop legacy python / remove six dependencies (#12639) 2019-01-03 15:50:05 +02:00
Dror Atariah 440c08684f FIX Add more validation for size parameters in train_test_split (#12733)
* Fixed typo in an example

* Removed un-needed lines from example

* Added tests on the validity of parameters

* Fixed error msg for train_size issue

* Added tests to check the validation of test and train sizes

* Switched to parameterized test

* Fixed typo in error msg

* Swithced to pytest.raises

* Swithced to pytest.raises also when checking msg

* Improved the validity tests and their unit testing
2018-12-19 12:36:53 +01:00
Bartosz Michałowski fa98a72dcc MNT Replaced all occurrences of assert_true and assert_false with assert (#12588) 2018-11-28 09:16:26 +08:00
Hanmin Qin 69c5dd9d85 TST Specify random seed in test_shuffle_kfold_stratifiedkfold_reproducibility (#12674) 2018-11-27 21:17:49 +01:00
Yaroslav Halchenko 362cb3bcab TST autoreplace assert_true(...==...) with plain assert (#12547) 2018-11-11 09:05:34 +08:00
Andreas Mueller 0f94f2962b
MNT simple deprecations and removals for 0.21 (#12238)
Part of #11992.
These were all the things that seemed pretty straight-forward. It's actually a bit bulky but should still be easy to review, hopefully.
2018-10-11 14:56:37 -04:00
Roman Yurchak ec69171d52 TST Use pytest.raises instead of legacy constructions (#12057) 2018-09-13 13:57:43 +02:00
Hanmin Qin 5533deb8e0 [MRG] FIX Support cv=None in *CV (#11761) 2018-08-07 11:53:59 +10:00
ZJ Poh adddf00433 [MRG] np.ones -> np.full (#11628) 2018-07-23 09:49:01 +02:00
Alexandre Boucaud f158e2dfe2 [MRG+1] Change CV defaults to 5 (#11557)
* add FutureWarning for methods with defaults=3

* add explicit cv values to fix assertion errors

* add tests for catching the FutureWarning

* Write current deprecation version

* Add deprecation in docstring

* change default cv value to None

* change cv from 3 to 5 in the examples

* upgrade doctests

* update doctest in tutorial

* update doctest in cross-validation doc

* fix tests

* add entry to whats new

* address Gael comments

* address Gael comments 2

* fix wrong indentation

* update doc

* add docstring deprecation warning in CV subclasses

* address Andy's comments

* fix PR number

* fix flake8

* add filterwarnings in tests

* fix doctests

* cv=None mendatory in Ridge

* fix warning related errors

* skip some doctests warnings

* make travis happy

* change from deprecated to versionchanged

* fix doctests and remove skipping

* address comments
2018-07-19 14:46:11 +02:00
Andreas Mueller 8e2c2aa35d
raise DeprecationWarnings and FutureWarnings as errors (#11570)
Towards #11252.
In the end we'd like to make these errors so we can keep this cleaner in the future.
2018-07-17 15:31:45 -05:00
Andreas Mueller eec7649236 MAINT Complete 0.20 deprecations (#9570) 2018-06-24 23:06:26 +10:00
Charlie Brummitt d074e403f1 [MRG+1] Fix bug in StratifiedShuffleSplit for multi-label data with targets having > 1000 labels (#9922)
* Use ' '.join(row) for multi-label targets in StratifiedShuffleSplit because str(row) uses an ellipsis when len(row) > 1000
* Add a new test for multilabel problems with more than a thousand labels
2017-10-17 09:44:35 +02:00
Andreas Mueller 94fa697356 [MRG+1] check that splitters handle 2d y and give reasonable errors on multilabel y (#9744) 2017-10-09 11:22:15 +02:00
Loïc Estève 4e6b403796 FIX test broken in numpy 1.14.dev due to array str changes 2017-09-29 16:34:52 +02:00
(Venkat) Raghav, Rajagopalan 75d6005fea [MRG] Add few more tests + Documentation for re-entrant cross-validation estimators (#7823)
* DOC Add NOTE that unless random_state is set, split will not be identical

* TST use np.testing.assert_equal for nested lists/arrays

* TST Make sure cv param can be a generator

* DOC rank_ becomes a link when rendered

* Use test_...

* Remove blank line; Add if shuffle is True

* Fix tests

* Explicitly test for GeneratorType

* TST Add the else clause

* TST Add comment on usage of np.testing.assert_array_equal

* TYPO

* MNT Remove if ;

* Address Joel's comments

* merge the identical points in doc

* DOC address Andy's comments

* Move comment to before the check for generator type
2017-07-17 08:58:59 +10:00
Nelson Liu 1f781e64a2 [MRG+3] CV splitters: train/test_size default behavior will change in 0.21 (#7459) 2017-06-14 21:28:52 +10:00
Vlad Niculae 93563b0ac1 [MRG+1] fix StratifiedShuffleSplit with 2d y (#9044)
* regression test and fix for 2d stratified shuffle split

* strengthen non-overlap sss tests

* clarify test and comment

* remove iter from tests, use str instead of hash
2017-06-13 17:40:45 +05:30
Naoya Kanai 95aa2952e1 Add logsumexp and comb to utils.fixes (#9046) 2017-06-10 15:01:02 +02:00
Alexandre Gramfort 32f2418a07 use ValueError 2017-06-08 11:44:54 +02:00
themrmax eaebfe0535 [MRG+1] add shuffle paramater to train_test_split (#8845)
* add shuffle paramater to train_test_split

* fix syntax error

* fix variable name

* fix formatting in doctest output

* fix doctest output

* refactor shuffle paramater into ShuffleSplit and StratifiedShuffleSplit

* include shuffle option in tests

* rollback refactor

* revert to simpler version of unshuffled split

* fix flake8 errors

* revert changes to ShuffleSplit

* revert BaseShuffleSplit

* more reversions

* fix indentation

* remove shuffle parameter from CVclass

* add text to NotImplementedError

* change indexing to use numpy.arange rather than range

* specify precondition for stratify to be None in docstring
2017-06-08 11:43:22 +02:00
Aman Dalmia 511c9a8655 [MRG+1] ENH: added max_train_size to TimeSeriesSplit (#8282)
* ENH: added max_train_size to TimeSeriesSplit

* FIX: update doctest

* FIX: correct error in the previous update

* FIX: added doctest fix for cross_validation.rst

* FIX: remove errors

* TST: tests updated and default value changed to None

* TST: improve split tests

* FIX: reduce code length
2017-06-08 10:51:40 +02:00
Hanmin Qin 41b84f84cc [MRG+1] Change the restriction of n_repeats in RepeatedKFold and RepeatedStratifiedKFold (#8909)
* change the restriction of n_repeats

* change test case
2017-06-05 16:51:17 +02:00
Toshihiro Kamishima 754109c78d [MRG+1] enable to use get_n_splits of LeaveOneGroupOut and LeavePGroupsOut with dummy parameters (#8794)
* remove needless argument checking

* add parameter checking as in LeavePGroupsOut

* add examples with dummy inputs

* add unittest for a get_n_splits method in LeaveOneGroupOut and LeavePGroupsOut classes

* X and y can be ommited in a get_n_splits function.

* fix error messages

* update examples

* fix test for an error message

* Revert "fix test for an error message"

This reverts commit 68b984207c.

* fix test for an error message

* fix error messages

* remove tailing white spaces

* add periods to messages

* test for ValueError’s of get_n_splits methods of LeaveOneOut / LeavePOut classes

* fix documents:
* parameter name: group -> groups
* modfy white space
2017-05-12 14:56:13 +02:00
AishwaryaRK b57837188d [MRG] Fixes #8736 add get_n_splits for RepeatedKFold and RepeatedStratifiedKFold (#8802) 2017-04-29 21:33:32 +10:00
Neeraj Gangwar af1796ef68 [MRG+1] Repeated K-Fold and Repeated Stratified K-Fold (#8120)
* Add _RepeatedSplits and RepeatedKFold class

* Add RepeatedStratifiedKFold and doc for repeated cvs

* Change default value of n_repeats

* Change input parameters of repeated cv constructor to n_splits, n_repeats, random_state

* Generate random states in split function rather than store it beforehand

* Doc changes, inheriting RepeatedKFold, RepeatedStratifiedKFold from _RepeatedSplits and other review changes

* Remove blank line, put testcases for deterministic split in loop and add StopIteration check in testcase

* Using rng directly as random_state param to create cv instance and added a check for cvargs

* Fix pep8 warnings

* Changing default values for n_splits and n_repeats and add entry in changelog

* Adding name to the feature

* Missing space
2017-03-04 15:39:04 -05:00
Loïc Estève 34968d4c5d Fix tests on numpy master (#7946)
Until now we were in a edge case on assert_array_equal
2016-11-29 21:50:56 +01:00
Loïc Estève e5bf61eee1 [MRG+1] Dropping python 2.6 support (#7890)
* Remove Python 2.6 support

Some details about some slightly orthogonal changes:
* Note about cheking safely for nan is likely not valid any more (commit
  introducing it is c80ca91b)
* scipy.linalg.qr econ parameter removed since scipy 0.9 in favour of
  mode='economic'
* Remove unnecessary libgfortran in conda create command

* Putative fix by setting the random seed

* Revert unintended change

* Reinstate previous logic for checking for NaNs

* Reinstate change in error message

Error messages from Python 2.7 assertRegexp does not contain the
function name, in contrast with Python 3 assertRegex
2016-11-23 17:11:04 -05:00
Raghav RV d7c956afc8 [MRG] FIX Validate and convert X, y and groups to ndarray before splitting (#7593) 2016-11-04 09:48:47 +11:00
Raghav RV 38f6a91566 [MRG + 2] FIX Be robust to non re-entrant/ non deterministic cv.split calls (#7660) 2016-10-31 08:49:17 +11:00
polmauri 73d3f03cfc [MRG + 1] FIX raise an error message when n_groups > number of groups (#7681) (#7683)
* FIX raise an error message when n_groups > actual number of groups (#7681)

This change addresses issue #7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.

* Make requested changes

- Check error message with `assert_raise_message`
- Pass parameters to `assert_raise_message` instead of defining functions

* Update condition and exception message
2016-10-25 11:42:39 -04:00
Russell Smith 54b0e4bf62 Add OneVs{One,All}Classifier._pairwise: fix for #7306 (#7350) 2016-09-20 13:46:45 +02:00
Raghav RV 9a12555e6d [MRG+1] ENH/MNT Rename labels --> groups in CV tools (#6660) 2016-09-11 19:14:41 +02:00
Andreas Mueller 31a4691d76 [MRG+1] fix sampling in stratified shuffle split (#6472)
Fix sampling in stratified shuffle split, break tests that test sampling.
2016-09-09 19:00:49 +02:00
Yen a7d748b1de Rename `TimeSeriesCV` to `TimeSeriesSplit` (#7245)
* rename TimeSeriesCV to TimeSeriesSplit

* Add TimeSeriesSplit

* Add whats new
2016-08-26 12:34:33 +10:00
Yen 234d25677d [MRG] Add homogeneous time series cross validation (#6586) 2016-08-24 23:15:38 +10:00
Nelson Liu 6766aea4dd
be more explicit about purpose of test 2016-08-18 23:21:35 -07:00
Nelson Liu da6c5c24eb
try to fix travis error 2016-08-18 12:08:40 -07:00
Nelson Liu 5f2297e47f
feature: add tests for sparse matrices 2016-08-18 11:40:26 -07:00
Yen 42120e50bb [MRG+1] Rename CV params n_{folds,iter} to n_splits (#7187)
* Rename n_iter to n_splits

* Fix bug

* Fix examples

* Add spaces

* Rename n_folds to n_splits

* Fix error

* Fix doc

* Fix doc

* Fix example

* Rename variables name

* PEP8

* Fix error message

* Add whats_new

* Fix test

* Fix doc

* Fix doc

* Make test clear
2016-08-16 13:56:55 -07:00
Loïc Estève 07728d9308 FIX StratifiedShuffleSplit train and test overlap
in some edge cases and added test.

Fix was applied in both sklearn.model_selection and
sklearn.cross_validation.
2016-02-26 08:25:25 +01:00
Raghav R V c4e0ce668c FIX/NRT signature expects the init to not be a c-defined method (Py2.7) 2016-02-11 13:36:21 +01:00
giorgiop 1814e848fb MAINT speed up test_split 2016-02-06 18:55:24 +01:00
dsquareindia 61486862a7 SKF raises error if n_labels<n_folds for individual classes. Updated whats_new 2016-01-21 12:07:28 +05:30
Raghav R V 2255ff5ee7 TST/FIX Make model selection tests warning free!
- Use data that will converge for the multioutput case
- Use atleast 3 samples per class to conform to 3fold cv
- Add the elided ignore warnings line
- Use the iris dataset to prevent non-convergence of sag solver
2016-01-17 15:48:44 -05:00
Olivier Grisel 280840f90f FIX boolean indexing in test_label_kfold 2015-12-24 17:53:46 +01:00
Raghav R V 3f8743f47b Main Commits - Major
--------------------

* ENH Reogranize classes/fn from grid_search into search.py
* ENH Reogranize classes/fn from cross_validation into split.py
* ENH Reogranize cls/fn from cross_validation/learning_curve into validate.py

* MAINT Merge _check_cv into check_cv inside the model_selection module
* MAINT Update all the imports to point to the model_selection module
* FIX use iter_cv to iterate throught the new style/old style cv objs
* TST Add tests for the new model_selection members
* ENH Wrap the old-style cv obj/iterables instead of using iter_cv

* ENH Use scipy's binomial coefficient function comb for calucation of nCk
* ENH Few enhancements to the split module
* ENH Improve check_cv input validation and docstring
* MAINT _get_test_folds(X, y, labels) --> _get_test_folds(labels)
* TST if 1d arrays for X introduce any errors
* ENH use 1d X arrays for all tests;
* ENH X_10 --> X (global var)

Minor
-----

* ENH _PartitionIterator --> _BaseCrossValidator;
* ENH CVIterator --> CVIterableWrapper
* TST Import the old SKF locally
* FIX/TST Clean up the split module's tests.
* DOC Improve documentation of the cv parameter
* COSMIT consistently hyphenate cross-validation/cross-validator
* TST Calculate n_samples from X
* COSMIT Use separate lines for each import.
* COSMIT cross_validation_generator --> cross_validator

Commits merged manually
-----------------------

* FIX Document the random_state attribute in RandomSearchCV
* MAINT Use check_cv instead of _check_cv
* ENH refactor OVO decision function, use it in SVC for sklearn-like
  decision_function shape
* FIX avoid memory cost when sampling from large parameter grids

ENH Major to Minor incremental enhancements to the model_selection

Squashed commit messages - (For reference)

Major
-----

* ENH p --> n_labels
* FIX *ShuffleSplit: all float/invalid type errors at init and int error at split
* FIX make PredefinedSplit accept test_folds in constructor; Cleanup docstrings
* ENH+TST KFold: make rng to be generated at every split call for reproducibility
* FIX/MAINT KFold: make shuffle a public attr
* FIX Make CVIterableWrapper private.
* FIX reuse len_cv instead of recalculating it
* FIX Prevent adding *SearchCV estimators from the old grid_search module
* re-FIX In all_estimators: the sorting to use only the 1st item (name)
    To avoid collision between the old and the new GridSearch classes.
* FIX test_validate.py: Use 2D X (1D X is being detected as a single sample)
* MAINT validate.py --> validation.py
* MAINT make the submodules private
* MAINT Support old cv/gs/lc until 0.19
* FIX/MAINT n_splits --> get_n_splits
* FIX/TST test_logistic.py/test_ovr_multinomial_iris:
    pass predefined folds as an iterable
* MAINT expose BaseCrossValidator
* Update the model_selection module with changes from master
  - From #5161
  -  - MAINT remove redundant p variable
  -  - Add check for sparse prediction in cross_val_predict
  - From #5201 - DOC improve random_state param doc
  - From #5190 - LabelKFold and test
  - From #4583 - LabelShuffleSplit and tests
  - From #5300 - shuffle the `labels` not the `indxs` in LabelKFold + tests
  - From #5378 - Make the GridSearchCV docs more accurate.
  - From #5458 - Remove shuffle from LabelKFold
  - From #5466(#4270) - Gaussian Process by Jan Metzen
  - From #4826 - Move custom error / warnings into sklearn.exception

Minor
-----

* ENH Make the KFold shuffling test stronger
* FIX/DOC Use the higher level model_selection module as ref
* DOC in check_cv "y : array-like, optional"
* DOC a supervised learning problem --> supervised learning problems
* DOC cross-validators --> cross-validation strategies
* DOC Correct Olivier Grisel's name ;)
* MINOR/FIX cv_indices --> kfold
* FIX/DOC Align the 'See also' section of the new KFold, LeaveOneOut
* TST/FIX imports on separate lines
* FIX use __class__ instead of classmethod
* TST/FIX import directly from model_selection
* COSMIT Relocate the random_state documentation
* COSMIT remove pass
* MAINT Remove deprecation warnings from old tests
* FIX correct import at test_split
* FIX/MAINT Move P_sparse, X, y defns to top; rm unused W_sparse, X_sparse
* FIX random state to avoid doctest failure
* TST n_splits and split wrapping of _CVIterableWrapper
* FIX/MAINT Use multilabel indicator matrix directly
* TST/DOC clarify why we conflate classes 0 and 1
* DOC add comment that this was taken from BaseEstimator
* FIX use of labels is not needed in stratified k fold
* Fix cross_validation reference
* Fix the labels param doc

FIX/DOC/MAINT Addressing the review comments by Arnaud and Andy

COSMIT Sort the members alphabetically
COSMIT len_cv --> n_splits
COSMIT Merge 2 if; FIX Use kwargs
DOC Add my name to the authors :D
DOC make labels parameter consistent
FIX Remove hack for boolean indices; + COSMIT idx --> indices; DOC Add Returns
COSMIT preds --> predictions
DOC Add Returns and neatly arrange X, y, labels
FIX idx(s)/ind(s)--> indice(s)
COSMIT Merge if and else to elif
COSMIT n --> n_samples
COSMIT Use bincount only once
COSMIT cls --> class_i / class_i (ith class indices) -->
perm_indices_class_i

FIX/ENH/TST Addressing the final reviews

COSMIT c --> count
FIX/TST make check_cv raise ValueError for string cv value
TST nested cv (gs inside cross_val_score) works for diff cvs
FIX/ENH Raise ValueError when labels is None for label based cvs;
TST if labels is being passed correctly to the cv and that the
ValueError is being propagated to the cross_val_score/predict and grid
search
FIX pass labels to cross_val_score
FIX use make_classification
DOC Add Returns; COSMIT Remove scaffolding
TST add a test to check the _build_repr helper
REVERT the old GS/RS should also be tested by the common tests.
ENH Add a tuple of all/label based CVS
FIX raise VE even at get_n_splits if labels is None
FIX Fabian's comments
PEP8
2015-10-23 17:28:08 +02:00