Commit Graph

1132 Commits

Author SHA1 Message Date
Taehoon Lee bdb00d17b9 Fix typos in test_covariance.py and extmath.py (#8997) 2017-06-06 16:54:51 +02:00
Andreas Mueller 1c41368bac [MRG+1] Uncontroversial fixes from estimator tags branch (#8086)
* some bug fixes.

* minor fixes to whatsnew

* typo in whatsnew

* add test for n_components = 1 transform in dict learning

* feature extraction doc fix

* fix broken test

* revert aggressive input validation changes

* in SelectFromModel, don't store threshold_ in transform. If we called "fit", use estimates from last "fit".

* move score from EllipticEnvelope to OutlierDetectionMixin

* revert changes to Tfidf documentation

* remove dummy input validation from whatsnew

* fix text feature tests

* rewrite from_model threshold again...

* remove stray condition

* fix self.estimator -> estimator, slightly more interesting test

* typo in comment

* Fix issues in SparseEncoder, add tests.
more explicit explanation of SparseEncoder change, add issue numbers to whatsnew

* minor fixes in whats_new.rst

* slightly more consistency with tuples for shapes

* not longer typo
2017-06-06 16:34:47 +02:00
Naoya Kanai bd0fc236e0 [MRG+1] MAINT drop SciPy < 0.13 (#8854)
Remove sklearn.utils.fixes functions that are not needed for scipy >= 0.13 and keep deprecated wrappers in other modules.
2017-06-02 23:36:33 +02:00
Guillaume Lemaitre 92cb166647 [MRG] DOC Homogeneous deprecation in docstring (#8907)
Update developers doc to use "deprecated" sphinx directive.
2017-05-23 08:42:08 +02:00
Clement Joudet 6252f99c16 [MRG+1] Fixing Math domain error on NMF due to numpy.dot (#8765)
* Fixing overflow error on NMF due to numpy.dot
2017-05-20 09:47:43 +02:00
Lera 8717a159ab [MRG] Extended explanation of using class_weight in RandomForestClassifier (Issue #6646) (#8838)
* Extended explanation of using class_weight in RandomForestClassifier

* Extended explanation of using class_weight in DecisionTreeClassifier,ExtraTreesClassifier and compute_sample_weight()

* Rephrased description.

* Rephrased description (remove "indicator")
2017-05-09 18:21:12 +10:00
Yichuan Liu 194c231d49 [MRG+1] Replace or remove VotingClassifier estimators by set_params (#7674)
* PR to 7288
Use _BaseComposition as base

*  Fix flakes problem

* Change ``pipeline``, add more tests and other changes
1. Use ``_BaseComposition`` in class ``Pipeline`` and ``FeatureUnion``
2. Add tests of soft voting ``transform`` when one estimator is set to None
3. Add estimator name validation in ``_BaseComposition`` and tests
4. Other requested changes.

* Remove the unused import warn

* Add more test and documentation

* resolve conflict with master

* Add testing cases and modify documentation

* Add to whats_new.rst

*  Fix too many blank lines
2017-04-10 15:04:48 -04:00
Guillaume Lemaitre e3c9ae204f [MRG+1] DOC improve description and consistency of random_state (#8689)
* DOC improve description of random_state in train_test_split

* DOC Make random_state consistent through documentation

* FIX reverse doc mistake

* FIX address comment of Tom

* DOC address comments

* DOC remove empty line

* DOC remove unecessary white spaces
2017-04-05 17:43:21 -07:00
RAKOTOARISON Herilalaina fb5a498d0b [MRG+1] Change named_steps to Bunch object (#8586)
* Change named_steps to Bunch object

* Update named_steps attribute documentation

* Add test for named steps bunch object

* Delete whitespace in test_pipeline

* Update test_pipeline.py

* Add comment for named_steps usage

* Move dataset/Bunch to utils

* Fix to PEP8 format

* Add __getattribute method to Bunch class, Fix pep8 bug

* Remove __getattribute__, update test_pipeline

* Update test with conflict and non-conflict named_steps

* Add reference to class Pipeline
2017-03-30 14:21:51 +02:00
guiniol 45d9182e6d [MRG+1] Fix float size in as_float_array (#8598)
* Fix float size in as_float_array

* Add tests for small ints in as_float_array

* Add test for object dtype

with minor tweaks
2017-03-21 16:13:48 +01:00
Peter Wang 4ab99c75b4 [MRG+1] FIX Correct depth formula in iforest (#8576)
* Fixed depth formula in iforest

* Added non-regression test for issue #8549

* reverted some whitespace changes

* Made changes to what's new and whitespace changes

* Update whats_new.rst

* Update whats_new.rst

* fixed faulty whitespace

* faulty whitespace fix and change to whats new

* added constants to iforest average_path_length and the according non regression test

* COSMIT

* Update whats_new.rst

* Corrected IsolationForest average path formula and added integer array equiv test

* changed line to under 80 char

* Update whats_new.rst

* Update whats_new.rst

* reran tests

* redefine np.euler_gamma

* added import statement for euler_gammma in iforest and test_iforest

* changed np.euler_gamma to euler_gamma

* fix small formatting issue

* fix small formatting issue

* modified average_path_length tests

* formatting fix + removed redundant tests

* fix import error

* retry remote server error

* retry remote server error

* retry remote server error

* re-added some iforest tests

* re-added some iforest tests
2017-03-14 16:50:23 +01:00
Shubham Bhardwaj 02c705e115 [MRG+1] Fixes #7578 added check_decision_proba_consistency in estimator_checks (#8253) 2017-03-07 07:10:10 +01:00
Kat Hempstalk daeba62b9c [MRG+2] Fixed assumption fit attribute means object is estimator. (#8418) 2017-02-21 14:20:05 +01:00
Marc Meketon a0db45db0e [MRG+1] Fix message formatting in exception (#8319)
when the missing class label is a string.
2017-02-21 10:03:38 +01:00
Denis A. Engemann 8694278c02 FIX/MAINT: update my mail etc (#8375)
* update mail etc

* fix utf8
2017-02-16 19:21:26 +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
chkoar ddd886baa8 FIX Add a missing space to an exception message in resample function (#8320) 2017-02-09 11:01:11 +11:00
Aman Dalmia c5bcdde895 TST: added test that sample_weight can be a list (#8261) 2017-02-03 18:54:30 +11:00
Ekaterina Krivich be305cebaf TST/FIX Add check for estimator: parameters not modified by `fit` (#7846)
ensure that estimators only add private attributes and attributes with
  trailing _

  in cases when existing estimators don't follow this new rule, we deprecate the
  attributes and make them follow this rule
2017-01-20 11:33:17 +11:00
Olivier Grisel 096a9cbead [MRG] MAINT Python 3.6 fixes (#8123)
* FIX dict order dependent doctest

* FIX str concat TypeError message changed in Python 3.6

* MAINT upgrade travis config with most recent conda deps
2016-12-27 19:50:25 +01:00
Josh Karnofsky e5ceda88f2 FIX check_array's accept_sparse param now takes true/false/str/list, but not None (#7937) 2016-12-20 21:45:43 +11:00
Andreas Mueller 5d0c7f5cdc [MRG+1] allow callable kernels in cross-validation (#8005) 2016-12-20 20:10:04 +11:00
Andreas Mueller 09b2df1bb0 left-over deprecation of 1d X (#8045) 2016-12-13 11:48:12 -05:00
Loïc Estève 5007e02c88 FIX .format arguments were in the wrong order
Add check_no_fit_attributes_set_in_init test and use name in the error
message rather than estimator since the former is more readable.
2016-12-13 11:32:43 +01:00
Loïc Estève e542efafe2 TST Ensure that attributes ending _ are not set in __init__ (#7464) 2016-12-12 21:57:43 +11:00
Andreas Mueller 5c4b1bb231 [MRG+1] Housekeeping Deprecations for v0.19 (#7927)
* remove stuff to be removed 0.19

* more changes

* remove classes from 0.19 whatsnew

* remove _LearntSelectorMixin

* remove ProjectedGradientNMF, load_lwf_*

* minor fixes

* remove more copy from logistic regression path

* remove lda, qda from __init__.__all__

* remove pg solver in nmf from tests etc

* remove class_weight="auto" from tests

* doctest change for decision_function_shape="ovr"

* remove transfrom from tree test, minor fixes to tree tests

* some fixes in the tests

* undo changes in functions which still allow 1d input...

* also allow 1d in scale

* more test fixes...

* last test fixes in forest and tree

* svm default value change doctest failures

* pep8

* remove more class_weight="auto" stuff

* minor cosmetics in docstrings deprecated / removed behavior.

* say that store_covariance has been moved to __init__ in discriminant_analysis
2016-12-09 12:43:38 -05:00
willduan 1f278e1c23 Fix version comparison for the numpy 1.12 beta (#7902) 2016-12-05 10:22:26 +01:00
Kathy Chen 04b67e2bcd [MRG+1] Fix estimators to work if sample_weight parameter is pandas Series type (#7825)
* addressed comments in the PR about parameters in check_array

* update the test case for the evaluation of estimators with pandas series

* bug fix, need to check for *not* None explicitly

* updated with isinstance check if the documentation says there is acceptance of floats

* ran pep8 linter on modified files

* moving the test case to estimators_check

* add a predict function into the testing pandas.Series class

* avoid running anything beyond the newly added meta checks

* check if pandas is installed before running the specific test

* changed the order of the try-catch to check for sample_weight param beforehand

* pass on import error rather than printing something to std out

* improve test case naming and pd.Series check in the bad estimator class

* address a pep8 linter error with unused import

* pep8 warning disabled for potential unused import

* throw a warning when SkipTest is raised

* add a SkipTestWarning

* updated the whats_new.rst with this issue

* rebase and fix a spacing issue
2016-12-03 15:56:22 -05:00
Joel Nothman 8570622a44 [MRG+1] DOC insert spaces before colons in parameter lists (#7920)
* DOC insert spaces before colons in parameter lists

Complies with numpydoc to improve rendering and automatic quality
assurance such as #7793. Affects listings of Parameters Attributes,
Returns.

Performed with the help of:

    grep -nE '^(    )+[a-zA-Z][a-zA-Z0-9_]*: ' sklearn -R | grep -v -e
    externals -e tests | grep -v -e default: -e else: -e Warning: -e Note:
    -e TRAIN: -e Default: -e True: -e False: -e DOI: -e In: | gsed
    's|\([^:]*\):\([0-9]*\):\([^:]*\):\(.*\)|--- a/\1\n+++ b/\1\n@@ -\2,1
    +\2,1 @@\n-\3:\4\n+\3 :\4|' | git apply --unidiff-zero -

* DOC fix numpydoc format for param
2016-11-25 10:59:22 +01:00
Loïc Estève 0847c92678 Replace ConvergenceWarning by RuntimeWarning (#7922)
when cumsum is unstable.
2016-11-24 12:05:44 +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
Ekaterina Krivich 02cc6f5d3a [MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (#7553)
* Add test for __dict__ for estimator checks

  check that "predict", "transform", "decision_function" or
"predict_proba" methods do not change the state of __dict__ of any
estimator

  see #7297

* Add a test to test_check_estimator

  that shows that check_estimator fails on an estimator that violates this

* Fixed bug where NMF's n_iter_ attribute was set by calls to transform
2016-11-05 21:44:53 +11:00
Loïc Estève 6a2d8d5bbc [MRG+2] BUILD Rewrite setup.py files to handle cython dependencies (#7719)
* Rewriting of cythonization in setup.py

By using Cython.Build.cythonize and switching between .c and .pyx files
as appropriate cython dependencies are correctly taken into account.

* Use cythonize once on the root config rather than in each subpackage

* Fix for Windows

* Remove caching from Travis

Cython dependencies are taken care of by Cython.Build.cythonize and
based on file timestamps, so .C and .so files will always be rebuild
from scratch on each build in Travis.

* Specify .pyx in setup.files for cython generated extensions

More natural this way. Tweak the extensions to generate from .c and .cpp
files for a release.

* COSMIT Remove commented out code

* Check cython version is greater than 0.23

* COSMIT better names for functions

* flake8 fix (imported module not at top of file)

* Install cython 0.23 for Python 2.6

now that cython >= 0.23 requirement is enforced in setup.py

* Use module constant for minimum required cython version

* Fix Travis install.sh

No easy way to put comments inside multi-line command
2016-11-02 22:57:04 +11:00
Josh Karnofsky edc9e7f151 [MRG] ENH faster sample_without_replacement for recent numpy (#7703) 2016-10-29 22:08:53 +11:00
Andreas Mueller 4da44c8541 [MRG+1] replaced some assert_true(np.allclose(x, y)) with assert_almost_equal (#7742)
* replaced some assert_true(np.allclose(x, y)) with assert_almost_equal for better error messages.

also some pep8.

* typo fixes
2016-10-25 09:15:58 -04:00
Antoine Wendlinger 74a9756fa7 [MRG+2] Norm inconsistency between RFE and SelectFromModel (was _LearntSelectorMixin) #2121 (#6181)
* Norm inconsistency between RFE and SelectFromModel (was _LearntSelectorMixin) #2121

* safe_pwr utility

* Norm fix

* Removed safe_pwr

* 1D arrays support for norm fix

* Test case for 2d coef in SelectFromModel

* Fix numpy version requirement for norm fix

* Implement fixes suggested by @jnothman

* Add numpy version requiring the fix.
2016-10-24 14:01:49 -04:00
Alexander Junge 568c002325 [MRG + 1] Move n_iter and get_params invariance tests to common estimator_checks (#7677)
* Test get_params invariance in common estimator tests

Remove test_get_params_invariance() from `test_common.py` and add
test call to _yield_all_tests() in `estimator_checks.py` to make
sure that get_params(deep=False) of a given Estimator returns a
subset of get_params(deep=True).

Compared to test_get_params_invariance(), it is NOT tested anymore
whether the given Estimator has an attribute get_params since
class BaseEstimator in `base.py` defines such an attribute
for each Estimator.

Partially addresses issue #7533
Also related to issue #4465

* Move test_transformer_n_iter() to estimator_checks.py

Remove the test test_transformer_n_iter() from tests/test_common.py
and perform the test logic in utils/estimator_checks.py instead.
Specifically, the method _yield_transformer_checks() now yields
check_transformer_n_iter() as part of the set of tests for
transformers.

test_transformer_n_iter() tests that that transformers with an
attribute max_iter, return the attribute of n_iter at least 1.

Partially addresses latter part of issue #7533

* Move test_non_transformer_estimators_n_iter() to estimator_checks.py

Remove the test_non_transformer_estimators_n_iter() from
tests/test_common.py; perform the test logic in
utils/estimator_checks.py instead.
Specifically, the method _yield_non_meta_checks() now yields
check_non_transformer_estimators_n_iter().

test_transformer_n_iter() tests that that estimators that are not
transformers with an attribute max_iter, return the attribute n_iter
of at least 1.

NOTE: The current implementation makes said test run for more
estimators than before this commit.
For some of these estimators, the test fails. This needs to be addressed
(see FIXME in line 111-115 of utils/estimator_checks.py for a potential
place to start).

Partially addresses latter part of issue #7533

* Fix check_non_transformer_estimators_n_iter calls

test_transformer_n_iter() test is now only run for
estimators where the test is applicable.

Partially addresses latter part of issue #7533

* Run check_non_transformer_estimators_n_iter on multi-class estimators

To do this, use helper method multioutput_estimator_convert_y_2d.
Also remove multi_output parameter from
check_non_transformer_estimators_n_iter since this parameter is not
used anywhere and corresponding cases should be handled by said
helper method.

Also, some pep8 line length fixes.

* Fix documentation for n_iter tests

There was some confusion between attributes and parameters.
Also rename n_iter to n_iter_
2016-10-20 10:23:15 -04:00
yangarbiter fa59873857 [MRG+1] FIX unstable cumsum (#7376)
* FIX unstable cumsum in utils.random

* equal_nan = true for isclose
since numpy < 1.9 sum is as unstable as cumsum, fallback to np.cumsum

* added axis parameter to stable_cumsum

* FIX unstable sumsum in ensemble.weight_boosting and utils.stats

* FIX axis problem in stable_cumsum

* FIX unstable cumsum in mixture.gmm and mixture.dpgmm

* FIX unstable cumsum in cluster.k_means_, decomposition.pca, and manifold.locally_linear

* FIX unstable sumsum in dataset.samples_generator

* added docstring for parameter axis of stable_cumsum

* added comment for why fall back to np.cumsum when np version < 1.9

* remove unneeded stable_cumsum

* added stable_cumsum's axis testing

* FIX numpy docstring for make_sparse_spd_matrix

* change stable_cumsum from error to warning
2016-10-17 15:49:23 +02: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
Iván Vallés 610461c030 TST ensure relationship between predict_proba and predict_log_proba (#7612) 2016-10-10 00:32:53 +11:00
Konstantin Podshumok 9b2aac9e5c [MRG + 1] [TST] (half-cosmetic) use less nose.tools import to simplify future transition to py.test (#7384)
* use less nose.tools import to simplify future transition to activly developing test suites/runners

* assert_equal -> assert_array_equal in test_feature_hasher_pairs_with_string_values

and one missed ImportError that should be replaced with AttributeError

* test for py2.6 compat with except AttributeError

* fix importing of SkipTest

* force using nose in python2.6 for now

* there was no assert_dict_equal in py2.6. but we can use assert_equal

although failed test will look a little bit ugly

* remove nose imports from doc/datasets
2016-10-07 12:46:52 -04:00
Andreas Mueller 280c70bf4f add numpy versions for backports / fixes 2016-10-04 11:20:12 -04:00
Andreas Mueller 1dff0aec21 clean up deprecation warning stuff in common tests
minor fixes in preprocessing tests
2016-09-22 19:35:31 +05:30
Nelle Varoquaux 46d337b8b7 Merge pull request #7412 from jnothman/fix_test_descriptions
[MRG+1] TST fix generated test names
2016-09-20 10:16:45 -07:00
Russell Smith 54b0e4bf62 Add OneVs{One,All}Classifier._pairwise: fix for #7306 (#7350) 2016-09-20 13:46:45 +02:00
Joel Nothman e222058dda Make named_check private 2016-09-16 06:46:50 +10:00
Mikhail Korobov 19aebe2431 use == instead of 'is' for string comparison (#7422) 2016-09-15 09:42:34 +10:00
Olivier Grisel d9bd30e2f7 FIX use == to avoid relying on string interning 2016-09-14 16:02:49 +02:00
Joel Nothman 1578eddef4 TST move test naming and use inspect 2016-09-14 11:11:04 +10:00
Joel Nothman 0d0b484e46 TST fix generated test names in case where test fails 2016-09-13 23:24:59 +10:00