Commit Graph

125 Commits

Author SHA1 Message Date
Rüdiger Busche d300f406ae MAINT Simplify super() calls (#12812) 2019-01-10 22:27:06 +01:00
Roman Yurchak 701144559f MAINT Remove unused utils.fixes (#12928)
This continues the work done in https://github.com/scikit-learn/scikit-learn/pull/12639 on dropping the python 2 support by,
 - ~~removing unnecessary `from __future__` imports~~
 - removing unused `sklearn.utils.fixes` assuming we can agree in https://github.com/scikit-learn/scikit-learn/issues/12927 that `sklearn.utils.fixes` are private as was stated e.g. in https://github.com/scikit-learn/scikit-learn/issues/6616#issuecomment-245109979
2019-01-08 12:43:49 +11:00
Thomas Moreau d25da1be20 FIX make joblib utils private, and remove mentions of externals.joblib (#12345) 2018-11-20 10:53:52 +11:00
Ming Li 1c88b3c9c7 Fix IncrementalPCA when final batch is smaller than dimensions required for SVD (#12379) 2018-10-31 14:32:19 +01:00
Didi Bar-Zev 9ec5a15823 ALL Add resample and shuffle to __all__ (#12456) 2018-10-26 11:00:01 +02:00
Roman Yurchak b42a5152af MAINT Fix test_logistic::test_dtype_match failure on 32 bit arch (#11899) 2018-08-25 11:54:30 +08:00
Olivier Grisel 40e6c43cb4
Joblib 0.12.2 (#11741)
* joblib 0.12.2

* Export _joblib's register_parallel_backend

* Use latest version of coverage
2018-08-03 12:34:25 +02:00
Nicolas Hug 6d15840432 DOC Fixed doc issues for utils module (#11445) 2018-07-22 15:23:11 +10:00
Ronan Lamy 5592a2eda9 [MRG] PyPy support for all but a couple of estimators (#11010) 2018-07-20 14:39:53 +10:00
Guillaume Lemaitre a365714481 [MRG+2] FIX enforce deterministic behaviour in BaseBagging (#9723)
* FIX enforce deterministic behaviour in BaseBagging

* DOC add entry in whats new for model changes

* add comments

* revert space

* revert space right place

* Typo

* FIX change estimators_samples_

* TST check size training set and hash during bootstrapping

* DOC/TST API entry in doc and style correction

* DOC move entry in the right section

* DOC add missing author and issue

* DOC add details in whats new entry

* FIX add hash from joblib in utils

* iter
2018-07-19 19:18:51 +02:00
Joel Nothman 14e7c328df Restructure access to vendored/site Joblib (#11471)
In order to fix #11408, this swaps `joblib` and `_joblib`. It however, allows users to access joblib's `Memory` or `Parallel` functionality without accessing `sklearn.externals._joblib` by importing `Memory`, `Parallel`, etc. into `sklearn.utils`.
2018-07-17 18:02:11 +02:00
Roman Yurchak c09352c241 [MRG] Fix DeprecationWarning due to collections.abc in Python 3.7 (#11431)
Closes https://github.com/scikit-learn/scikit-learn/issues/11121

This PR removes the deprecation warning about ABC being moved from `collections` to `collections.abc` when importing scikit-learn in Python 3.7.

In the end, I put `collections.abc.{Sequence, Iterable, Mapping, Sized}` in the namespace of `sklearn.utils.fixes`. This was the simplest way I could find, and while it has the drawback of obfuscating the real module name, other approached appeared more problematic and a similar approach is currently used e.g. for `utils.fixes.signature` which is an alias for `inspect.signature`.

We can't just patch six with https://github.com/benjaminp/six/pull/241, because sklearn uses six from 5 years ago, which would  need updating and I'm not sure if it could have side effects (e.g. for pickling backward compatibility etc).

**Edit**: This adds a test checking that generally no warnings are raised when importing scikit-learn top-level modules.
2018-07-14 15:14:02 -05:00
jeremiedbb 0d8a04bd17 [MRG+1] SimpleImputer(strategy="constant") (#11211) 2018-06-20 17:20:33 +02:00
Joel Nothman ef8d22af7c
ENH Add working_memory global config for chunked operations (#10280) 2018-05-25 12:04:05 +10:00
Loïc Estève 20661b5018
TST: only run doctests on numpy 1.14. (#10835)
Fix doctests due to numpy 1.14 formatting changes.
2018-03-27 07:44:40 +02:00
Mohamed Ali Jamaoui e161700c6f DOC add example to sklearn.utils.indices_to_mask (#10749) 2018-03-05 17:59:31 +11:00
Angus Williams 47cf43d44a [MRG+1] DOC Fix utils.resample and utils.shuffle docstrings: 'views' -> 'copies' (#10162) 2017-11-17 17:22:05 +01:00
Kumar Ashutosh b441308f36 Fixes deprecation warning in numpy-dev build (#9683) 2017-09-04 10:00:15 +02:00
Loïc Estève 682e85fb1a Fix safe_indexing with read-only indices (#9507) 2017-08-08 10:21:09 +02:00
Guillaume Lemaitre 93d0766e1f [MRG] DOC add non support of COO safe indexing (#9423) 2017-07-20 22:10:46 +10:00
(Venkat) Raghav, Rajagopalan b6f8865b0a [MRG + 1 (rv) + 1 (alex) + 1] Add a check to test the docstring params and their order (#9206)
* add automatic test of docstrings for function / method signatures using numpydoc
2017-07-11 18:42:10 +02:00
Joel Nothman e31c4f1e9e DOC List more utils in API ref (#8827) 2017-06-08 15:31:26 +02: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
chkoar ddd886baa8 FIX Add a missing space to an exception message in resample function (#8320) 2017-02-09 11:01:11 +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
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
David Staub 277b058713 [MRG] Remove heavy memory footprint in BaseBagging due to OOB scoring (#7118)
* Remove heavy memory footprint for OOB scoring from bagging.

- Remove `estimators_samples` attribute from `BaseBagging`
- Add method `_get_estimators_samples` to `BaseBagging` that
  returns a generator producing sample indices on demand.
- Slight refactor of `_parallel_build_estimators()` to
  isolate and group lines accessing random state.

* Replaced `BaseBagging.estimators_samples_` attribute with property.

- Accessing `BaseBagging.estimators_samples_` now triggers call to
  `BaseBagging._get_estimators_samples` as well as deprecation
  warning for release 0.20.
- This should make the fix for the OOB memory issue fully backwards
  compatible.

* Remove print statement.

* Added test, made new method more general.
- Added test to `test_bagging.py` to ensure that indices generated
  on the fly are identical to indices generated at fit time.
- Refactored `_get_estimators_samples()` to `_get_estimators_indices()`,
  now both feature and samples indices are returned.
- Refactored `estimators_samples_()` to deal with above.

* Rename index generating functions and arguments.

* `estimators_samples_()` returns list instead of generator

* Removed `estimators_samples_` deprection warning.

* Actually removed `estimators_samples_` deprecation warning.

* New mask generation function, new bagging test, new BaseBagging attributes.
- Added new private function in bagging.py that converts indices to
  a boolean mask.
- Added new bagging test to make sure identical OOB scores are generated
  when the same estimator if fit with fixed random state and identical
  training data.
- Added new private attributes `BaseBagging._max_features` and
  `BaseBagging._max_samples` to store validated input values.

* Streamlined code, improved `estimators_samples_()` documentation.
- Removed `max_samples` argument from `_parallel_build_estimators()`,
  this value is now accessed via `ensemble._max_samples`.
- Removed validation of `ensemble.max_features` and `max_samples`,
  instead use `ensemble._max_features` and `ensemble._max_samples`
  which are assumed to be already validated.
- Removed unnecessary `samples` variable from `_parallel_build_estimators()`.
- Changed the way `random_state` is generated in `_parallel_build_estimators()`
  and `BaseBagging._get_estimators_data_draws()` to direct numpy method to
  reflect that seeds created in `BaseBagging._fit()` are trustworthy.
- Due to above removed generation of new seed for each estimator in
  `_parallel_build_estimators()` and `BaseBagging._get_estimators_data_draws()`.
- Added documentation to `BaseBagging.estimators_samples_()` property
  indicating the reason it's generated dynamically and the associated performance
  penalty.
- Returned `BaggingClassifier._set_oob_score()` and `BaggingRegressor._set_oob_score()`
  to directly accessing `self.estimators_samples_`.

* Streamlined code, improved `estimators_samples_()` documentation.
- Removed `max_samples` argument from `_parallel_build_estimators()`,
  this value is now accessed via `ensemble._max_samples`.
- Removed validation of `ensemble.max_features` and `max_samples`,
  instead use `ensemble._max_features` and `ensemble._max_samples`
  which are assumed to be already validated.
- Removed unnecessary `samples` variable from `_parallel_build_estimators()`.
- Changed the way `random_state` is generated in `_parallel_build_estimators()`
  and `BaseBagging._get_estimators_data_draws()` to direct numpy method to
  reflect that seeds created in `BaseBagging._fit()` are trustworthy.
- Due to above removed generation of new seed for each estimator in
  `_parallel_build_estimators()` and `BaseBagging._get_estimators_data_draws()`.
- Added documentation to `BaseBagging.estimators_samples_()` property
  indicating the reason it's generated dynamically and the associated performance
  penalty.
- Returned `BaggingClassifier._set_oob_score()` and `BaggingRegressor._set_oob_score()`
  to directly accessing `self.estimators_samples_`.

* PEP8, remove optional arguments, add public function to utils.
- Update indentation and line length to conform to PEP8.
- Update `estimators_samples_()` docstring to conform to PEP8 and
  PEP257.
- Remove optional arguments to `BaseBagging._get_estimators_data_draws()`,
  rename to `BaseBagging._get_estimators_indices()`.
- Remove optional arguments from `_generate_mask_from_indices()`,
  move to `utils.metaestimators`, rename to `indices_to_mask()`.

* Add indices_to_mask to __all__ in utils.metaestimators

* Move utils function, new test for `estimators_samples` correctness.
- Moved `indices_to_mask` from `utils.metaestimators` to `utils.validation`
- Added new test to `ensemble.test_bagging` to make sure refitting
  an individual estimator from the bagging ensemble using the corresponding
  samples identified in `BaseBagging.estimators_samples` returns the same model.

* Adjust/remove tests, move `indices_to_mask` to `utils.__init__`.
- Remove test_bagging.test_consistent_index_sampling
- Update formatting checks in test_bagging.test_estimators_samples
  to make sure each mask is numpy boolean array
- Move indices_to_mask from utils.validation to utils.__init__

* update class docstring for `estimators_samples_`

- Updated class docstring of `estimators_samples_` attribute for `BaggingClassifier` and `BaggingRegressor` to indicate that samples are identified with boolean masks.

* PEP8, made `max_samples` arg optional in _fit()
- Fixed PEP8 issues.
- Gave `max_samples` argument of `BaseBagging._fit()` a default
  value of `None` as indicated in the docstring. Added code to
  check for and process `None` value.
- Added a few more comments to `_fit()`.

* 2 new `max_samples` consistency tests, update whats_new.rst

* Minor change

* Update whats_new.rst
2016-08-23 16:59:32 +10:00
ningchi 6ce198c78f [MRG] #6581 n_samples of utils.resample can be more when replace is True
* #6581 n_samples can be more when replace is True

* more compact code
2016-04-02 08:58:40 +02:00
MechCoder 7e79adca9d Huber regressor
Add gradient calculation in _huber_loss_and_gradient

Add tests to check the correctness of the loss and gradient

Fix for old scipy

Add parameter sigma for robust linear regression

Add gradient formula to robust _huber_loss_and_gradient

Add fit_intercept option and fix tests

Add docs to HuberRegressor and the helper functions

Add example demonstrating ridge_regression vs huber_regression

Add sample_weight implementation

Add scaling invariant huber test

Remove exp and add bounds to fmin_l_bfgs_b

Add sparse data support

Add more tests and refactoring of code

Add narrative docs

review huber regressor

Minor additions to docs and tests

Minor fixes that deals with dealing with NaN values in targets
and old verions of SciPy and NumPy

Add HuberRegressor to robust estimator

Refactored computation of gradient and make docs render properly

Temp

Remove float64 dtype conversion

trivial optimizations and add a note about R

Remove sample_weights special_casing

address @amueller comments
2016-02-25 16:31:08 -05:00
Raghav R V a228016585 Leading underscores for warnings imported from sklearn.exceptions
in other modules where warnings are deprecated.

Prefix warnings imported from sklearn.exceptions instead of
suffixing to prevent showing both the suffixed warning
and the deprecated warning during tab completion.
2016-01-08 12:40:10 -05:00
Raghav R V 857cb09254 FIX/ENH Make the moved class resilient to the deprecation patching 2015-10-20 01:24:35 +02:00
Raghav R V 61ae8d56c4 MAINT move deprecated into deprecation.py 2015-10-19 22:35:36 +02:00
Raghav R V e3afc0e8c9 MAINT move custom error/warning classes into sklearn.exceptions
ENH NonBLASDotWarning -> EfficiencyWarning; Improve error message
DOC Add exceptions module to modules/classes.rst
MAINT Move ConvergenceWarning, UndefinedMetricWarning et al into exceptions
MAINT Remove ChangedBehaviorWarning from base
DOC/FIX Improve DataConversionWarning's docstring
2015-10-19 22:35:35 +02:00
Vighnesh Birodkar 2f099334f9 MAINT deprecate 1d input arrays for all estimators
Passing 1D arrays to check_array, without setting `ensure_2d` to false now
raises a deprecation warning before reshaping it. This will later throw an
error.

All Scaler classes also throw warnings when 1D arrays are passed.

All unit tests/doctests are modified to ensure that no 1D arrays are passed,
except in explicit 1D array tests where the warnings have been silenced.

Additional tests are also included which check for different 1D array cases.

2D array tests with one samples and one features are also added and where
they failed, `check_array` call has been modified to give a more useful error
message
2015-09-09 15:49:58 +02:00
Andreas Mueller 990a6b402f FIX n_jobs slicing bug in dict learning, add input validation to gen_even_slices 2015-05-20 15:29:25 -04:00
TomDLT 89c1018c64 ENH improve check_array
ENH improve check_array to warn on dtype conversions

ENH make check_array accept several dtypes

ENH change validation with improved check_array

ENH change astype to avoid copy if possible

ENH remove warn_if_not_float
2015-05-19 16:13:42 +02:00
Andreas Mueller cdfaabfa0b FIX work-around for read only dataframes 2015-05-05 19:26:35 -04:00
Olivier Grisel e12863f103 FIX make shuffle / resample pass-through indexing utilities 2015-04-10 16:11:22 -04:00
Andreas Mueller e1af92b640 remove cross_validation.Bootstrap 2015-03-18 14:51:37 -04:00
Raghav R V a59eee8fc9 FIX Add check_symmetric to __all__ 2015-02-24 18:16:20 -05:00
trevorstephens c5fadff91c add compute_sample_weight util 2015-01-31 18:26:41 -08:00
Raghav R V b3fbccca38 FIX various mismatch between docstring and signature params
DOC max_iterations -> max_iter. Make it consistent with kmeans

MAINT Replace the deprecated dx parameter with d in the docstrings

MAINT Deprecation warning for max_iterations parameter.
2015-01-16 11:54:57 -05:00
Jake VanderPlas a21957e85c rename ensure_symmetric -> test_symmetric 2014-12-29 08:36:25 -08:00
Jake VanderPlas 7794d90471 MAINT: create ensure_symmetric utility function to check matrix symmetry 2014-12-28 21:02:35 -08:00
Olivier Grisel f0fe4afd1e Merge pull request #2949 from FlorianWilhelm/theilsen
[MRG+1] TheilSen robust linear regression
2014-11-20 15:34:01 +01:00
Olivier Grisel fe553b755a ENH use specific warning class for RP 2014-11-18 14:55:56 +01:00
Florian Wilhelm a5d2fd915a Merge branch 'master' into theilsen
Conflicts:
	doc/modules/model_evaluation.rst
2014-10-09 17:43:21 +02:00
Will Lamond 766fb56ec0 FIX allow ndim>2 in shuffle
Fixes #3694.
2014-09-25 19:29:44 +02:00
Florian Wilhelm a8000405de COSMIT: Small changes regarding Theil-Sen
- Typo fixed in linear_model documenation
- Usage of matplotlib.pyplot instead of matplotlib.pylab
- Removed trailing backslash in import statements
- Renamed _modweiszfeld_step to _modified_weiszfeld_step
- Renamed variable fst to first_elem in _lstq
- Made get_n_jobs private in utils/__init__.py
2014-09-24 19:58:21 +02:00