Commit Graph

61 Commits

Author SHA1 Message Date
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
Hanmin Qin e19bb7ce5a Fix n_splits in KFold instantiation in model_selection tests (#8910) 2017-05-21 01:35:02 -04: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
akshay0724 676e863024 [MRG+1] Fix ug in BaseSearchCV.inverse_transform (#8348) 2017-02-17 17:12:51 +01:00
Stephen Hoover eee8be490b [MRG+1] Add classes_ parameter to hyperparameter CV classes (#8295) 2017-02-10 08:36:20 +01:00
Stephen Hoover 3a0ea190c5 [MRG+1] Accept keyword parameters to hyperparameter search fit methods (#8278)
* ENH Accept keyword parameters to hyperparameter search fit methods

Deprecate ``fit_params`` as a constructor argument to the hyperparameter search classes and instead accept keyword parameters to the ``fit`` methods. This makes the ``fit`` methods of these functions conform to the Estimator API and allows the use of hyperparameter search functions in other CV utility functions such as ``cross_val_predict``.

* CR: Expanded tests, remove deprecated use in Ridge

* Make tests consistent in Python 2 and 3
2017-02-09 07:42:23 +01:00
Aman Dalmia fd84a567b4 [MRG + 1] Fix the cross_val_predict function for method='predict_proba' (#7889)
Handle the case where different CV splits have different sets of classes present.
2017-01-08 09:24:05 +11:00
(Venkat) Raghav (Rajagopalan) 2f7f5a1a50 [MRG + 1] Add fowlkess-mallows and other supervised cluster metrics to SCORERS dict so it can be used in hyper-param search (#8117)
* Add supervised cluster metrics to metrics.scorers

* Add all the supervised cluster metrics to the tests

* Add test for fowlkes_mallows_score in unsupervised grid search

* COSMIT: Clarify comment on CLUSTER_SCORERS

* Fix doctest
2017-01-06 12:03:10 +01:00
Stijn Tonk 986a49bbe0 FIX Split data using _safe_split in _permutaion_test_score (#5697)
Squashed commits:
[94fd9f4] split data using _safe_split in _permutaion_test_scorer
[522053b] adding test case test_permutation_test_score_pandas() to check if permutation_test_score plays nice with pandas dataframe/series
[21b23ce] running test_permutation_test_score_pandas on iris data to prevent warnings.
[15a48bf] adding safe_indexing to _shuffle function
[9ea5c9e] adding test case test_permutation_test_score_pandas() to check if permutation_test_score plays nice with pandas dataframe/series
[3cf5e8f] split  data using _safe_split in _permutaion_test_scorer to fix error when using Pandas DataFrame/Series
2016-12-29 02:46:53 +01:00
Andreas Mueller 5d0c7f5cdc [MRG+1] allow callable kernels in cross-validation (#8005) 2016-12-20 20:10:04 +11: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
Andreas Mueller 716819b5a3 explain learning_curve(shuffle=True) test. 2016-10-20 10:08:37 -04:00
NarineK 829efa5929 [MRG+1] Learning curve: Add an option to randomly choose indices for different training sizes (#7506)
* Chooses randomly the indices for different training sizes

* Bring back deleted line

* Rewrote the description of 'shuffle' attribute

* use random.sample instead of np.random.choice

* replace tabs with spaces

* merge to master

* Added shuffle in model-selection's learning_curve method

* Added shuffle for incremental learning + addressed Joel's comment

* Shorten long lines

* Add 2 blank spaces between test cases

* Addressed Joel's review comments

* Added 2 blank lines between methods

* Added non regression test for learning_curve with shuffle

* Fixed indentions

* Fixed space issues

* Modified test cases + small code improvements

* Fix some style issues

* Addressed Joel's comments - removed _shuffle_train_indices, more test cases and added new entry under 0.19/enhancements

* Added some modifications in whats_new.rst
2016-10-19 15:18:07 -04:00
Raghav RV 868a58b2e0 [MRG+1] FIX Make sure GridSearchCV and RandomizedSearchCV are pickle-able (#7594)
* FIX Subclass a new MaskedArray which allows pickling even when dype=object

* TST unpickling too

* FIX Use MaskedArray from utils.fixes rather than from numpy

* FIX imports

* Don't assign a variable

* FIX np --> numpy

* Use tostring instead of tobytes for old numpy

* COSMIT pickle-able --> picklable

* use #noqa comment to turn off flake8

* TST/ENH Check if the pickled est's predict matches with the original one's
2016-10-10 15:33:44 -04:00
Raghav RV 3619bd386b BUGFIX _store train_scores only if return_train_score is True (#7535) 2016-09-29 20:53:25 -07:00
Raghav RV b444cc9c64 [MRG+2] Timing and training score in GridSearchCV (#7325)
* Resolved issue #6894 and #6895:
    Now *SearchCV.results_ includes both timing and training scores.

wrote new test (sklearn/model_selection/test_search.py)
and new doctest (sklearn/model_selection/_search.py)
added a few more lines in the docstring of GridSearchCV and RandomizedSearchCV.
Revised code according to suggestions.
Add a few more lines to test_grid_search_results():
    1. check test_rank_score always >= 1
    2. check all regular scores (test/train_mean/std_score) and timing >= 0
    3. check all regular scores <= 1
Note that timing can be greater than 1 in general, and std of regular scores
always <= 1 because the scores are bounded between 0 and 1.

* ENH/FIX timing and training score.

* ENH separate fit / score times
* Make score_time=0 if errored; Ignore warnings in test
* Cleanup docstrings
* ENH Use helper to store the results
* Move fit time computation to else of try...except...else
* DOC readable sample scores
* COSMIT Add a commnent on why time test is >= 0 instead of > 0
  (Windows time.time precision is not accurate enought to be non-zero
   for trivial fits)

* Convey that times are in seconds
2016-09-27 20:14:33 +10:00
Russell Smith 54b0e4bf62 Add OneVs{One,All}Classifier._pairwise: fix for #7306 (#7350) 2016-09-20 13:46:45 +02:00
Yichuan Liu 3dffa08e43 FIX 7155: GridSearchCV predict_proba delegation to SDGClassifier 2016-09-12 20:47:21 +02:00
Raghav RV b18b1611cd [MRG+1] TST Stronger test for _check_is_permutation (#7395)
* TST Stronger test for _check_is_permutation

* TST Ensure additional duplicate indices are caught
2016-09-12 11:44:16 -04: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
Gael Varoquaux 4b2304f05a Merge pull request #7261 from betatim/negative-scorers
[MRG + 2] Rename scorers like `mse` to `neg_mse`
2016-09-08 20:40:17 +02:00
b0noI a03db89eba [MRG+1] Support of the collections.Sequence type has been added to the _check_param_grid method from model_selection. (#7323)
* Support of the collections.Sequence type has been added to the _check_param_grid method from model_selection.

* test_grid_search_when_param_grid_includes_range test was refactored (parts that are not nessesary have been removed).

* test_grid_search_bad_param_grid now checks that value is not string. This is important since string is a Sequence.

* _check_param_grid now checks is the type is not string together with the check for other types.

* whats_new.rst has been updated to include information about bug fix for bug #7322.

* Description of the fix for the bug #7322 has been updated.

* Fix for indented in model_selection._search.py.
2016-09-07 17:06:44 -04:00
Raghav R V 4dbab2680e results_ --> cv_results_; "test_mean_score" --> "mean_test_score" et al. 2016-09-06 18:46:09 +02:00
Olivier Grisel db56cf467e Merge pull request #7216 from b0noI/master
[MRG+1] New text for the ValueError that is thrown by _check_param_grid method
2016-08-31 15:27:58 +02:00
Viacheslav V Kovalevskyi 47eae84f8d MockClassifier has been added to the _grid_search tests. 2016-08-29 20:48:36 -07:00
Viacheslav V Kovalevskyi 401d2a178c Test method test_grid_search_incorrect_param_grid has been renamed to test_grid_search_param_grid_includes_sequence_of_a_zero_length. 2016-08-28 16:30:49 -07:00
Viacheslav V Kovalevskyi 058546215f Tests that are checking that _grid_search method throws correct ValueError have been added. 2016-08-28 15:31:33 -07:00
Tim Head 9d695d730f Keep old metric names for deprecation period
Maintain old names during the deprecation period and update
tests to use better variables names.
2016-08-27 21:11:38 +02:00
Tim Head ef64969f91 Introduce deprecation warning and fix tests
get_scrorer now warns if you use an old name for a scorer
and tests have been updated to use new naming convention.
2016-08-27 14:56:40 +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
Raghav RV 114d8b1b4d ENH Better error message when refit=True. (#7234) 2016-08-25 11:27:18 +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
Raghav R V afd5d18b0c [MRG] ENH Restructure grid_scores_ into a dict of 1D arrays
Also, DOC what's new section for model_selection changes
2016-06-16 12:23:04 +10:00
Olivier Grisel 70d7fecaab FIX workaround bug in numpy 1.9 (#6856)
Also use dtype with explicit precision (as a good practice) although
this does not impact the outcome of this test.
2016-06-03 19:10:01 +02:00
Joel Nothman 814223cbfd [MRG+1] FIX support memmap scalars as CV scores (#6789)
* FIX support memmap scalars as CV scores

* FIX test for Python 3.5 and NumPy 1.12
2016-06-01 23:34:16 -07:00
Gael Varoquaux e42a370010 Merge pull request #6274 from jakevdp/setup_py_fix
[MRG+1] MAINT: Make sure all tests are included with installation
2016-05-19 16:21:23 +02:00
Raghav R V dc42bde3e9 FIX Don't warn when scoring param is passed + PEP8 (#6798) 2016-05-19 08:50:46 +02:00
Jake VanderPlas 304f4b55d5 TST: make model_selection test an absolute import 2016-05-13 06:57:09 -07:00
Jake VanderPlas 1cc4e9a0a7 TST: fix relative import in model_selection tests 2016-05-13 06:57:09 -07:00