Commit Graph

58 Commits

Author SHA1 Message Date
Rüdiger Busche d300f406ae MAINT Simplify super() calls (#12812) 2019-01-10 22:27:06 +01:00
Roman Yurchak 684d8a221d MAINT Use set litterals when possible (#12667) 2019-01-06 19:21:45 +08:00
Andreas Mueller 952ef6637a MRG Drop legacy python / remove six dependencies (#12639) 2019-01-03 15:50:05 +02: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
Marc Torrellas f6f7e3cfd3 [MRG + 2] Print train scores in _fit_and_score (#12613)
* print train scores when verbose > 3 in _fit_and_score

* train_scores computed if verbose > 3, and 3 decimals places only

* flake8 warnings solved

* print train score if return_train_score
test coverage increased

* added test for multimetric;
tests cleaned using pytest parametrize

* fixing failed tests for python2...

* revert changes in _scorer

* modified whats_new

* modified whats_new again
2018-11-21 20:22:24 -05:00
Yaroslav Halchenko 362cb3bcab TST autoreplace assert_true(...==...) with plain assert (#12547) 2018-11-11 09:05:34 +08:00
Nicolas Hug 4e2da4af92 [MRG] Added FutureWarning in sgd models for tol parameter (#12399)
* Added ChangedBehaviorWarning in sgd models

if tol is None while max_iter is set

* Changed to FutureWarning and clarified None meaning

* Ignored warningin tests

* Ignore warnings in tests, round 2
2018-10-24 11:00:43 -04:00
Andreas Mueller fb7be879a3 [MRG + 1] return_train_score deprecation (#12241) 2018-10-03 19:24:14 +02:00
Hanmin Qin b915ca6fd8
MNT Avoid using "is" when comparing strings (#12168) 2018-09-26 14:32:09 +08:00
Guillaume Lemaitre 5431a1a9bf BUG: check equality instead of identity in check_cv (#12155) 2018-09-25 19:00:27 +08:00
Joel Nothman 7ed61a24fe ENH add multi_class='auto' for LogisticRegression, default from 0.22; default solver will be 'lbfgs' (#11905)
* Change default solver in LogisticRegression
* This is an API change, not a feature
* Decrease numerical precision in LogisticRegression doctest
* ENH add multi_class='auto' for LR, default from 0.22
* No warning when binary
2018-08-26 23:00:02 +03:00
Samuel O. Ronsin 6b38970fce ENH Expose errors_score in cross_validate and cross_val_score (#11583) 2018-07-27 12:27:16 +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
jeremiedbb 0d8a04bd17 [MRG+1] SimpleImputer(strategy="constant") (#11211) 2018-06-20 17:20:33 +02:00
Roman Yurchak e8d8b8eeb0 TST: parametrize unit tests (#11074)
yield tests are deprecated in pytest and will be removed in pytest 4.0.
They all have been replaced by parametrize.
2018-06-08 14:59:33 +02:00
Gaurav Dhingra eed83790b0 ENH Change default gamma from 'auto' to 'scale' in SVC (#10331) 2018-03-10 10:39:21 +08:00
Kirill 76b5b2af57 ENH Change default error_score to raise-deprecating (#10677) 2018-03-02 18:32:42 +11:00
Aurélien Bellet d9c212297e ENH add option to cross_validate to return estimators fitted on each split (#9686) 2018-02-28 09:32:46 +11:00
Kumar Ashutosh 71b29acbfb [MRG+2] Moves Imputation out of Preprocessing (#10483) 2018-02-15 06:47:06 +11:00
ksemb 77418a0275 MAINT Fix escape sequences that are deprecated in Python 3.6 (#10578)
https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
2018-02-07 10:41:21 +11:00
Mayur Kulkarni 92c9095591 [MRG+1] FIX Improve message and exception of cross-validation FitFailedWarning (#10382) 2018-01-10 16:20:05 -08:00
Joel Nothman 85d670c3b1 Duplicate import 2017-10-20 18:17:11 +11:00
Reiichiro Nakano ebc8730344 [MRG+1] Fix cross_val_predict behavior for binary classification in decision_function (Fixes #9589) (#9593)
* fix cross_val_predict for binary classification in decision_function

* Add unit tests

* Add unit tests

* Add unit tests

* better fix

* fix conflict

* fix broken

* only calculate n_classes if one of 'decision_function', 'predict_proba', 'predict_log_proba'

* add test for SVC ovo in cross_val_predict

* flake8 fix

* fix case of ovo and imbalanced folds for binary classification

* change assert_raises to assert_raise_message for ovo case

* fix flake8 linetoo long

* add comments and clearer tests

* improve comments and error message for OvO

* fix .format error with L

* use assert_raises_regex for better error message

* raise error in decision_function special cases. change predict_log_proba missing classes to minimum numpy value

* fix broken tests due to special cases of decision_function

* add modified test for decision_function behavior that does not trigger edge cases

* fix typos

* fix typos

* escape regex .

* escape regex .

* address comments. one unaddressed comment

* simplify code

* flake

* wrong classes range

* address comments. adjust error message

* add warning

* change warning to runtimewarning

* add test for the warning

* Use assert_warns_message rather than assert_warns

Other minor fixes

* Note on class-absent replacement values

* Improve error message
2017-10-19 17:05:43 -04:00
Kumar Ashutosh 766ba93208 [MRG+1] DEPREC Change default for return_train_score to False (#9677) 2017-10-18 10:38:53 +11:00
James Bourbeau 8f89478d58 [MRG + 1] Removes estimator method check in cross_val_predict before fitting (#9641)
* Removes check in cross_val_predict that checks estimator method before fitting

* Adds regression test for issue #9639
2017-08-29 18:13:53 -07:00
Rasul Kerimov 9e9b78dfaa [MRG+1] Resolve the problem with cross_val_predict(method=) when passing X or y as list (#9600)
* issue 9592

* issue resolve

* resolve issue

* review

* Delete sample.py

* review
2017-08-21 22:43:30 -07:00
Andreas Mueller 0dd19de33a fix wrong assert in test_validation (#9480) 2017-08-03 07:39:46 +10:00
(Venkat) Raghav, Rajagopalan add9b7f8f9 [MRG] [HOTFIX] Fix capitalization in test and hence fix failing travis at master (#9317)
* Fix capitalization in test and hence fix master

* Fix error message

* ENH fix tests with full error message
2017-07-10 23:18:24 +02:00
(Venkat) Raghav, Rajagopalan a08555a238 [MRG + 2] ENH Allow `cross_val_score`, `GridSearchCV` et al. to evaluate on multiple metrics (#7388)
* ENH cross_val_score now supports multiple metrics

* DOCFIX permutation_test_score

* ENH validate multiple metric scorers

* ENH Move validation of multimetric scoring param out

* ENH GridSearchCV and RandomizedSearchCV now support multiple metrics

* EXA Add an example demonstrating the multiple metric in GridSearchCV

* ENH Let check_multimetric_scoring tell if its multimetric or not

* FIX For single metric name of scorer should remain 'score'

* ENH validation_curve and learning_curve now support multiple metrics

* MNT move _aggregate_score_dicts helper into _validation.py

* TST More testing/ Fixing scores to the correct values

* EXA Add cross_val_score to multimetric example

* Rename to multiple_metric_evaluation.py

* MNT Remove scaffolding

* FIX doctest imports

* FIX wrap the scorer and unwrap the score when using _score() in rfe

* TST Cleanup the tests. Test for is_multimetric too

* TST Make sure it registers as single metric when scoring is of that type

* PEP8

* Don't use dict comprehension to make it work in python2.6

* ENH/FIX/TST grid_scores_ should not be available for multimetric evaluation

* FIX+TST delegated methods NA when multimetric is enabled...

TST Add general tests to GridSearchCV and RandomizedSearchCV

* ENH add option to disable delegation on multimetric scoring

* Remove old function from __all__

* flake8

* FIX revert disable_on_multimetric

* stash

* Fix incorrect rebase

* [ci skip]

* Make sure refit works as expected and remove irrelevant tests

* Allow passing standard scorers by name in multimetric scorers

* Fix example

* flake8

* Address reviews

* Fix indentation

* Ensure {'acc': 'accuracy'} and ['precision'] are valid inputs

* Test that for single metric, 'score' is a key

* Typos

* Fix incorrect rebase

* Compare multimetric grid search with multiple single metric searches

* Test X, y list and pandas input; Test multimetric for unsupervised grid search

* Fix tests; Unsupervised multimetric gs will not pass until #8117 is merged

* Make a plot of Precision vs ROC AUC for RandomForest varying the n_estimators

* Add example to grid_search.rst

* Use the classic tuning of C param in SVM instead of estimators in RF

* FIX Remove scoring arg in deafult scorer test

* flake8

* Search for min_samples_split in DTC; Also show f-score

* REVIEW Make check_multimetric_scoring private

* FIX Add more samples to see if 3% mismatch on 32 bit systems gets fixed

* REVIEW Plot best score; Shorten legends

* REVIEW/COSMIT multimetric --> multi-metric

* REVIEW Mark the best scores of P/R scores too

* Revert "FIX Add more samples to see if 3% mismatch on 32 bit systems gets fixed"

This reverts commit ba766d98353380a186fbc3dade211670ee72726d.

* ENH Use looping for iid testing

* FIX use param grid as scipy's stats dist in 0.12 do not accept seed

* ENH more looping less code; Use small non-noisy dataset

* FIX Use named arg after expanded args

* TST More testing of the refit parameter

* Test that in multimetric search refit to single metric, the delegated methods
  work as expected.
* Test that setting probability=False works with multimetric too
* Test refit=False gives sensible error

* COSMIT multimetric --> multi-metric

* REV Correct example doc

* COSMIT

* REVIEW Make tests stronger; Fix bugs in _check_multimetric_scorer

* REVIEW refit param: Raise for empty strings

* TST Invalid refit params

* REVIEW Use <scorer_name> alone; recall --> Recall

* REV specify when we expect scorers to not be None

* FLAKE8

* REVERT multimetrics in learning_curve and validation_curve

* REVIEW Simpler coding style

* COSMIT

* COSMIT

* REV Compress example a bit. Move comment to top

* FIX fit_grid_point's previous API must be preserved

* Flake8

* TST Use loop; Compare with single-metric

* REVIEW Use dict-comprehension instead of helper

* REVIEW Remove redundant test

* Fix tests incorrect braces

* COSMIT

* REVIEW Use regexp

* REV Simplify aggregation of score dicts

* FIX precision and accuracy test

* FIX doctest and flake8

* TST the best_* attributes multimetric with single metric

* Address @jnothman's review

* Address more comments \o/

* DOCFIXES

* Fix use the validated fit_param from fit's arguments

* Revert alpha to a lower value as before

* Using def instead of lambda

* Address @jnothman's review batch 1: Fix tests / Doc fixes

* Remove superfluous tests

* Remove more superfluous testing

* TST/FIX loop over refit and check found n_clusters

* Cosmetic touches

* Use zip instead of manually listing the keys

* Fix inverse_transform

* FIX bug in fit_grid_point; Allow only single score

TST if fit_grid_point works as intended

* ENH Use only ROC-AUC and F1-score

* Fix typos and flake8; Address Andy's reviews

MNT Add a comment on why we do such a transpose + some fixes

* ENH Better error messages for incorrect multimetric scoring values +...

ENH Avoid exception traceback while using incorrect scoring string

* Dict keys must be of string type only

* 1. Better error message for invalid scoring 2...
Internal functions return single score for single metric scoring

* Fix test failures and shuffle tests

* Avoid wrapping scorer as dict in learning_curve

* Remove doc example as asked for

* Some leftover ones

* Don't wrap scorer in validation_curve either

* Add a doc example and skip it as dict order fails doctest

* Import zip from six for python2.7 compat

* Make cross_val_score return a cv_results-like dict

* Add relevant sections to userguide

* Flake8 fixes

* Add whatsnew and fix broken links

* Use AUC and accuracy instead of f1

* Fix failing doctests cross_validation.rst

* DOC add the wrapper example for metrics that return multiple return values

* Address andy's comments

* Be less weird

* Address more of andy's comments

* Make a separate cross_validate function to return dict and a cross_val_score

* Update the docs to reflect the new cross_validate function

* Add cross_validate to toc-tree

* Add more tests on type of cross_validate return and time limits

* FIX failing doctests

* FIX ensure keys are not plural

* DOC fix

* Address some pending comments

* Remove the comment as it is irrelevant now

* Remove excess blank line

* Fix flake8 inconsistencies

* Allow fit_times to be 0 to conform with windows precision

* DOC specify how refit param is to be set in multiple metric case

* TST ensure cross_validate works for string single metrics + address @jnothman's reviews

* Doc fixes

* Remove the shape and transform parameter of _aggregate_score_dicts

* Address Joel's doc comments

* Fix broken doctest

* Fix the spurious file

* Address Andy's comments

* MNT Remove erroneous entry

* Address Andy's comments

* FIX broken links

* Update whats_new.rst

missing newline
2017-07-07 11:12:31 -04:00
Tom Dupré la Tour edeb3af217 Deprecate n_iter in SGDClassifier and implement max_iter (#5036) 2017-06-23 21:49:29 +02:00
Aleksandr Sandrovskii 49b730f9fb [MRG+2] Clone estimator for each parameter value in validation_curve (#9119) 2017-06-14 17:12:40 +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
Stephen Hoover eee8be490b [MRG+1] Add classes_ parameter to hyperparameter CV classes (#8295) 2017-02-10 08:36:20 +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
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
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
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 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
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 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
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