Commit Graph

73 Commits

Author SHA1 Message Date
Rüdiger Busche d300f406ae MAINT Simplify super() calls (#12812) 2019-01-10 22:27:06 +01:00
Andreas Mueller 952ef6637a MRG Drop legacy python / remove six dependencies (#12639) 2019-01-03 15:50:05 +02:00
Andreas Mueller b32076f581 DOC better explain bootstrap option in forests and bagging (#12875) 2018-12-28 13:19:27 +08:00
Thomas Moreau d25da1be20 FIX make joblib utils private, and remove mentions of externals.joblib (#12345) 2018-11-20 10:53:52 +11:00
Olivier Grisel 664ff3474f ENH Prefer threads for IsolationForest (#12543) 2018-11-07 14:50:04 +01:00
Connossor 5cef1df11b FIX ensure max_features > 0 in ensemble.bagging (#12388) 2018-10-27 11:22:20 +02:00
Rebekah Kim 9d58ca5ad4 MNT Remove duplicate import of warnings & unused variables (#12203) 2018-09-30 08:11:25 +08:00
Adrin Jalali 8a5ff27e2f DOC BaggingRegressor missing default value for oob_score in docstring (#12108) 2018-09-19 11:59:07 +08:00
Hanmin Qin 9b8fd0b0d0 DOC Correct default n_jobs & reference the glossary (#11808)
Also improves the glossary entry for n_jobs.
2018-08-18 19:57:10 +10: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
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
Zach Griffith c690943aa8 [MRG+1] DOC: Change verbose attribute description to include predict for forest classes. (#11218) 2018-06-10 13:45:16 +10:00
Jimmy Wan a31a9067b3 ENH Update BaggingRegressor to relax checking X for finite values (#9707) 2018-05-31 12:41:13 +10:00
Mohamed Ali Jamaoui 58f84694a8 DOC Add reference to the glossary in the warm_start parameter description of public APIs (#10699) 2018-02-26 20:21:17 +08:00
Joel Nothman c3bdc0a89a
DOC clean up assorted type specifications (#10441) 2018-01-11 09:11:17 +11:00
Joel Nothman 4c78855827 DOC Fix markup in docstring 2017-11-13 22:11:32 +11:00
Sebastin Santy 924a4661ee [MRG + 1] Too few arguments in formatting call (#9298)
* Too few arguments in formatting call

* Add test

* Covered with tests
2017-07-13 23:48:04 +02:00
Taehoon Lee d69395f4fb DOC Fix typos (#9229) 2017-06-27 11:58:46 +10:00
mlewis1729 af412822a4 [MRG+1] fixed OOB_Score bug for bagging classifiers. (#8936)
* fixed OOB_Score bug for bagging slassifiers.
See: https://github.com/scikit-learn/scikit-learn/issues/8933

* Added white space

* more white space fixing

* Adding test for oob_score validity

* removing pandas, replacing with numpy matrices

* fixing white space

* more white space fixing

* white space ...

* fixed labels to allow for strings

* white space

* simplifying test

* white space

* reformatting test

* white space

* pressed enter at end of file

* removing line at end of file
2017-06-08 11:35:48 +02:00
Naoya Kanai 6579220588 [MRG+1] Drop NumPy < 1.8 (#8874) 2017-06-07 17:06:06 +02:00
Aman Dalmia c5bcdde895 TST: added test that sample_weight can be a list (#8261) 2017-02-03 18:54:30 +11: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
Joel Nothman 32d1236f4a [MRG+2] FIX adaboost estimators not randomising correctly (#7411)
* FIX adaboost estimators not randomising correctly

(fixes #7408)

FIX ensure nested random_state is set in ensembles

* DOC add what's new

* Only affect *__random_state, not *_random_state for now

* TST More informative assertions for ensemble tests

* More specific testing of different random_states
2016-09-23 17:00:32 +10: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
Lilian Besson e8a8a6751f Two typo on my change, sorry
- total_n_estimators should be sum(n_estimators) not len(..)
- keyword argument should be after non-keyword argument (call of ``_parallel_build_estimators`` with ``delayed`` on line 365-366.
2016-03-16 00:11:00 +01:00
Lilian Besson b286b85d23 Add and print a total_n_estimators information
Add to bagging.Bagging._parallel_build_estimators a total_n_estimators parameter, to improve the (optional) information printed if verbose > 1.

It felt weird to see 6 times in a row "building estimator 1 of 1" without any idea of total number of estimators to build, now it's fixed.
2016-03-14 23:49:38 +01:00
YenChenLin 46fc1be145 Remove redundant words in sklearn 2016-02-23 16:54:03 +08:00
Tim Head 7c425abcd6 base_estimator_ attribute is a single estimator not a list 2016-01-04 18:37:56 +01:00
Gilles Louppe 889e2d4024 Merge pull request #5678 from betatim/no-warning-iforest
[MRG+1] IsolationForest max_samples warning and calculation
2015-11-11 15:02:37 +01:00
Tim Head 6f6ec7fb00 Reference correct variable 2015-11-09 14:37:09 +01:00
Tim Head 7af49dfeed Fix doc string and number vs string ordering 2015-11-04 17:34:10 +01:00
Tim Head bc85b78b12 Test max_samples_ attribute, set max_depth in BaseBagging 2015-11-04 08:35:42 +01:00
KamalakerDadi f2e35411fa Added more versions of 0.17 2015-11-04 00:02:52 +01:00
KamalakerDadi d3a8f85c55 Added more documentation of version adds 2015-11-03 23:57:19 +01:00
ngoix a75eb63194 iforest
example + benchmark

explanation

make some private functions + fix public API

IForest using BaseForest base class for trees

debug + plot_iforest

classic anomaly detection datasets and benchmark

small modif

BaseBagging inheritance

shuffle dataset before benchmarking

BaseBagging inheritance

remove class label 4 from shuttle dataset

pep8 + rm shuttle.csv bench_IsolationForest.png + doc decision_function

add tests

remove comments

fetching kddcup99 and shuttle datasets

fetching kddcup99 and shuttle datasets

pep8

fetching kddcup99 and shuttle datasets

pep8

new files iforest.py and test_iforest.py

sc

alternative to pandas (but very slow)
in kddcup99.py

faster parser

sc

pep8 + cleanup + simplification

example outlier detection

clean and correct

idem

random_state added

percent10=True in benchmark

mc

remove shuttle + minor changes

sc

undo modif on forest.py and recompile cython on _tree.c

fix travis

cosmit

change bagging to fix travis

Revert "change bagging to fix travis"

This reverts commit 30ea500eb818c7a2c6ea5c3d63e75c6935aa3a35.

add max_samples_ in BaseBagging.fit to fix travis

mc

API : don't add fit param but use a private _fit + update tests + examples to avoid warning

adapt to the new structure of _tree.pyx

cosmit

add performance test for iforest

add _tree.c _utils.c _criterion.c

TST : pass on tests

remove test

relax roc-auc to fix AppVeyor

add test on toy samples

Handle depth averaging at python level

plot example: rm html add png

load_kddcup99 -> fetch_kddcup99 + doc

Take into account arjoly comments

sh -> shuffle

add decision_path code from #5487 to bench

Take into account arjoly comments

Revert "add decision_path code from #5487 to bench"

This reverts commit 46ad44ab487f4fd2728d927cbe09000330e8663e.

fix bug with max_samples != int
2015-10-24 15:17:32 +02:00
MechCoder 80e22b3ddf Patch liblinear for sample_weights in LogisticRegression(and CV) 2015-10-23 00:00:31 -04:00
Jiali Mei 85223b9bcc a common test to check if classifiers fail when fed regression targets 2015-10-14 14:46:13 -04:00
vstolbunov ebd5dbc68a Fixed syntax and combined two test functions 2015-09-15 12:40:08 -04:00
Valentin Stolbunov 1a15fdc4f5 Added handling of sample weights in logistic.py
* Updated _check_solver_option to include sample_weight check
* Updated all calls to _check_solver_option()
* Updated documentation of class_weight throughout logistic.py
* Added sample_weight parameter to logistic_regression_path.
* Added handling of sample weights to logistic_regression_path.
* Added sample_weight parameter to _log_reg_scoring_path.
* Added handling of sample weights to _log_reg_scoring_path.
* Added sample_weight parameter to fit() in the LogisticRegression class.
* Added handling of sample sample weights in LogisticRegression.fit()
* Added sample_weight parameter to fit() in the LogisticRegressionCV class.
* Added handling of sample weights in LogisticRegressionCV.fit()
* Added test_logistic_regressioncv_sample_weights, which:
  * tests that a ValueError is raised if liblinear is used with
    sample weights
  * tests that passing sample weights as np.ones(y.shape[0]) is
    the same as not passing them (default None)
  * tests that using both lbfgs and newton-cg solvers with
    sample weights yields the same results
  * tests that passing class weights to scale one class is the
    same as passing sample weights for the training data of just
    that class
* Fixed bug with *= in logistic_regression_path.
* Fixed bug in test_logistic_regressioncv_sample_weights where
  no data was created prior to fitting.
* Changes to accepted sample_weight type.
* Fixed bug in naming of sample_weight when passed from
  _log_reg_scoring_path to logistic_regression_path.
* Fixed issue of sample_weight=None being converted to np.array()
  and then not being reconigzed as None.
* Added tests for LogisticRegression
* Attempting to fix same issue as 9d3becf by instead implementing
  if statement in bagging.py.
* Added TODO to eliminate check for liblinear w/ sample weights
  in bagging.py
2015-09-15 12:40:08 -04:00
Matti Lyra 4f6cd637ea Changed predict_log_proba so that it accepts sparse matrices. 2015-09-08 08:43:11 +02:00
Matti Lyra e648fb9bc4 Added the option of passing in a sparse X matrix into decision function, plus tests for sparse for all prediction functions. 2015-09-07 18:05:42 +02:00
Andreas Mueller 434ee958aa test for accepted sparse matrices 2015-08-26 22:00:55 -04:00
Andreas Mueller 0650d5502e DOC adding backlinks to docstrings 2015-06-03 00:24:04 -04:00
Tim Head 8add36bdb9 Better assert_raises use, API compliance, better ordering
Removed the need for printing attributes to raise
exceptions in the tests

Removed unnecessary setting of attributes in the
initialisation.

Moved check for warm_start and oob_score
2015-05-06 15:14:06 +02:00
Tim Head 919684cdf4 Keep estimators_samples_ and estimators_features_ across warmstarts
Keep these attributes as well as estimators_ when adding more
estimators via warm_start=True
2015-05-06 15:14:06 +02:00
Tim Head fb9e7254c6 oob_score will only be calculated if warm_start=False 2015-05-06 15:14:06 +02:00
Tim Head d83a362a6d Removed overly deep indentation 2015-05-06 15:14:06 +02:00
Tim Head 4408a180cc Test for unchanged n_estimator and indentation fix
Added a test to check nothing happens when calling
fit() without changing n_estimators. Fixed indentation
in fit() for this case.
2015-05-06 15:14:06 +02:00
Tim Head 2f563df512 Added warm_start to bagging
BaggingClassifier and BaggingRegressor now support warm_starts. Added
basic tests and documentation of the new functionality. Heavily
inspired by work on warm_start for Random forests.
2015-05-06 15:14:05 +02:00