Commit Graph

413 Commits

Author SHA1 Message Date
Thomas J. Fan 5572a342bb
MNT Replace PriorityHeap with cpp heap methods in trees (#22630) 2022-03-03 10:32:44 +01:00
Thomas J. Fan 5291239923
MNT Small refactor of cost complexity pruning using _TREE_UNDEFINED (#22351) 2022-02-28 17:42:57 +01:00
Thomas J. Fan 70eebb992e
MNT Use C++ stack instead of implementing our own in trees (#22328) 2022-02-25 17:54:54 +01:00
Loïc Estève 8dcde1e4d4
Support cross 32bit/64bit pickles for decision tree (#21552)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
2021-11-25 17:08:51 +01:00
Jérémie du Boisberranger 1f8825c8dd
MNT Centralize common cython compiler directives (#21512) 2021-11-03 13:26:23 +01:00
Jérémie du Boisberranger ef71c8597e
MNT Clean deprecations for 1.0 | trees (#19336) 2021-06-15 18:18:47 +02:00
Fatos Morina 9694d5a4b5
Remove the unused import of csc_matrix (#19989) 2021-04-27 12:37:56 +02:00
Qi Zhang e217b68fd0
FIX Fix a cross-platform endian issue in trees (#17644)
* fixed a cross-platform endian issue

* removed a duplicated dtype checking

* Trigger [arm64] CI

* added an entry to doc/whats_new/v0.24.rst

* moved my fix entry to sklearn.tree section

* Update sklearn/tree/_tree.pyx

Added comments

Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>

* code simplified

* fixed a typo in sklearn/tree/_tree.pyx

* Update doc/whats_new/v0.24.rst

Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>

* updated doc/whats_new/v0.24.rst

* Update sklearn/tree/_tree.pyx

Added a space after "if", to be PEP8 compliant.

Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>

* Update sklearn/tree/_tree.pyx

Co-authored-by: Qi Zhang <q.zhang@ibm.com>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
2020-08-12 16:43:09 +02:00
Jorge Gorbe Moya c11aaf5a66
FIX undefined behavior in _tree.pyx and _quad_tree.pyx (#17228)
* Fix undefined behavior in _tree.pyx and  _quad_tree.pyx

Accessing a member through a null pointer is undefined behavior, even if
no actual memory access is performed (like in this case, where it was
used only for offset computation). See the following link for an
explanation:
https://software.intel.com/content/www/us/en/develop/blogs/null-pointer-dereferencing-causes-undefined-behavior.html

The current approach will also fail when building with tools like ubsan
(undefined behavior sanitizer).

The standard way to compute offsets of struct members is the offsetof
macro but it seems it's not supported by Cython so I've used the
approach described here:

https://mail.python.org/pipermail/cython-devel/2013-April/003505.html

* Simplify definitions of types for numpy.

According to
9e9cdb0192 (issuecomment-638998985)
these dictionaries with offsets are there for old numpy versions and
they are no longer needed. We can use instead an approach similar to
https://github.com/scikit-learn/scikit-learn/pull/15097/files#diff-b071106a87a03ee4e9149e3f0a2b1180L187

I have verified that tests keep passing and that the undefined behavior
that motivated this pull request in the first place is still fixed.

* Document the new numpy type definition approach.

Added a brief comment and a link to stackoverflow thread that explain
why the simpler approach to define numpy types works.

* Fix typo 'dtyle'->'dtype'
2020-06-22 14:11:58 +02:00
Roman Yurchak 8ab0064579
MNT Fix build with Cython 3.0a5 (#17627) 2020-06-18 15:10:11 +02:00
Juan Carlos Alfaro Jiménez e4ebcbcafd
MNT Deprecate X_idx_sorted in tree module (#17614) 2020-06-17 13:58:47 -04:00
Alexandre Batisse 0db80b90c7
FIX support of float32 read only input in trees (#16331) 2020-02-01 15:08:22 +01:00
Roman Yurchak af8a6e592a MAINT Use C99 functions from Cython (#15098) 2019-09-28 23:19:31 -04:00
Thomas J Fan 67c94c7e2a Add Minimal Cost-Complexity Pruning to Decision Trees (#12887) 2019-08-20 09:02:45 -04:00
Nicolas Hug 0eaaeafd1b EHN Fast PDPs for histogram-based GBDT (#13769) 2019-07-11 14:52:55 +02:00
Thomas J Fan 581b0e1d73 MAINT Fix GCC warnings from Cython (#14077) 2019-07-01 18:55:29 +02:00
Nicolas Hug 4de404d46d MNT Cleaning for fast partial dependence computation (#13738) 2019-05-03 09:00:25 +10:00
jeremiedbb cad0fb434f MNT Use a common language_level cython directive (#13630) 2019-04-13 07:30:18 +02:00
Roman Yurchak 49570484db MAINT Use cython language_level=3 directive (#12873) 2019-02-28 18:45:15 +01:00
Adrin Jalali 90570ab031 MNT simplify some tree code with memoryviews (#12886)
* simplify apply_dense with memoryviews

* change more Xs to memviews in splitter

* remove commented out lines

* trying to remove y_stride

* float->dtype_t

* criterion has no more y_stride

* remove redundant constructs and handle const y input

* fix criterion docstring for y's dtype

* revert docstring for y

* formatting: no space between type name and [:, :]

* remove redundant X

* more cleanup on criterion

* address comment
2019-02-28 16:44:49 +01:00
hhu-luqi 337448f589 MAINT Remove unused `cdef double threshold` in _tree.pyx (#13230) 2019-02-25 11:05:26 +01:00
Adrin Jalali 02dc9ed680 Fix max_depth overshoot in BFS expansion of trees (#12344)
* fix the issue with max_depth and BestFirstTreeBuilder

* fix the test

* fix max_depth overshoot in BFS expansion

* fix forest tests

* remove the warning, add whats_new entry

* remove extra line

* add affected classes to changed classes

* add other affected estimators to the whats_new changed models

* shorten whats_new changed models entry
2018-11-13 13:10:33 -05:00
Adrin Jalali a80bbd9403 ENH add get_n_leaves() and get_max_depth() to DesicionTrees (#12300) 2018-10-10 22:01:11 +11:00
Taehoon Lee ebf2bf8107 Fix typos (#9205) 2017-06-23 11:43:46 +02:00
(Venkat) Raghav (Rajagopalan) fc2f24927f [MRG+1] ENH/FIX Introduce min_impurity_decrease param for early stopping based on impurity; Deprecate min_impurity_split (#8449)
[MRG+2] ENH/FIX Introduce min_impurity_decrease param for early stopping based on impurity; Deprecate min_impurity_split
2017-04-03 09:38:53 -07:00
(Venkat) Raghav (Rajagopalan) 4907029b1d [MRG+3] FIX Memory leak in MAE; Use safe_realloc; Acquire GIL only when raising; Propagate all errors to python interpreter level (#7811) (#8002)
* FIX MAE reg. criterion: Use safe_realloc to avoid memory leak

* Release GIL in safe_realloc and clean up scaffolding

* As gil is released in safe_realloc, no need of a with gil block

* Use except * to propagate error in all cdef functions

* Don't use except * for functions that return python objects

* Don't use except * for the comparison function passed to qsort

* Omissions and Errors

* Use safe_realloc now that gil is released there

* Fix realloc size

* Acquire GIL only if we need to raise

* Use except * more judiciously; Release gil only when raising; Add comments to clarify

* Actually that was unneeded; realloc will also allocate for the first time

* StackRecord*, PriorityHeapRecord* to fused type realloc_ptr; Use safe_realloc

* Use except -1 to propagate exceptions. This should avoid overheads

* Fix docstrings and add return 0 to reset methods

* TYPO

* REVIEW Remove redundant MemoryError raising calls
2017-01-19 00:58:16 +01:00
Ibraim Ganiev 74e4c422bd FIX #6420: Cloning decision tree estimators breaks criterion objects (#7680) 2016-10-20 10:10:50 +11:00
Ibraim Ganiev 78dbcb2838 [MRG] fix #6101 GradientBoosting decision_function for sparse inputs (#6116) 2016-10-15 21:41:44 +11:00
Nelson Liu 2f4b661a91 [MRG+1] correct condition in decision tree construction (#7441)
* remove unused condition in decision tree construction

* edit is_leaf condition for min_weight_leaf

* edit ordering of statements

* remove extra parens and add whats new
2016-09-29 14:34:23 +02:00
CeShine Lee 0e1fd12d1e DOC Correction: max_depth is effective when max_leaf_nodes is not None (#7183) 2016-08-17 07:57:05 +10:00
Nelson Liu 376aa50e70 [MRG+1] feature: add beta-threshold early stopping for decision tree growth (#6954)
* feature: add beta-threshold early stopping for decision tree growth

* check if value of beta is greater than or equal to 0

* test if default value of beta is 0 and edit input validation error message

* feature: separately validate beta for reg. and clf., and add tests for it

* feature: add beta to forest-based ensemble methods

* feature: add separate condition to determine that beta is float

* feature: add beta to gradient boosting estimators

* rename parameter to min_impurity_split, edit input validation and associated tests

* chore: fix spacing in forest and force recompilation of grad boosting extension

* remove trivial comment in grad boost and add whats new

* edit wording in test comment / rebuild

* rename constant with the same name as our parameter

* edit line length for what's new

* remove constant and set min_impurity_split to 1e-7 by default

* fix docstrings for new default

* fix defaults in gradientboosting and forest classes
2016-07-27 17:46:49 +02:00
Gael Varoquaux 1837224751 Merge pull request #6613 from nelson-liu/correct_license_spelling
[MRG+1] DOC: fix spellings of 'license'
2016-06-15 13:58:59 +02:00
Raghav R V f254ce295e ENH move the raise statement alone inside a gil block (#6644) 2016-04-14 17:59:00 +02:00
Nelson Liu d2aaf0f4bb doc: fix spellings of 'license' 2016-03-31 17:25:31 -07:00
Lars Buitinck 2e4aafd19c MAINT remove my email address
I'm getting too many individual support requests. People should
use the mailing list.
2016-03-04 10:43:41 +01:00
YenChenLin 46fc1be145 Remove redundant words in sklearn 2016-02-23 16:54:03 +08:00
Arnaud Joly 7fc96a0cb9 ENH don't unpickle capacity, but infer it 2015-10-23 16:44:41 +02:00
Arnaud Joly d53772d4a2 FIX serialization bug in the implementation of the pickle protocol 2015-10-23 15:56:27 +02:00
Arnaud Joly bc02bd5243 ENH rename decision_paths to decision_path 2015-10-21 17:05:56 +02:00
Arnaud Joly f6d605ff96 Implement decision path in tree 2015-10-21 17:05:55 +02:00
Jacob Schreiber 02c0029baa ENH gbt sparse support 2015-09-28 13:44:12 -07:00
Jacob Schreiber 5978c0bbdf ENH split _tree.pyx into several files 2015-09-09 11:28:24 +02:00
Arnaud Joly 251feccc4c ENH Faster tree-based methods by implementing reverse update of criterion
The idea is to take into account the linear properties of the impurity
between the prospective left, right and parents splits.
2015-09-07 13:59:50 +02:00
Arnaud Joly d39716e817 Optimize MSE criterion
By avoiding computing constant terms during split optimization.
2015-09-07 09:10:16 +02:00
Gilles Louppe 25f893969c DOC: fixes to _tree.pyx 2015-07-31 09:31:33 +02:00
Jacob Schreiber 3a135f5748 Final round of revisions 2015-07-30 18:20:37 +02:00
Jacob Schreiber a91aac0867 PEP257 adhered to closer 2015-07-23 13:16:26 +02:00
Jacob Schreiber 7d0c734797 Responses changed to targets 2015-07-23 10:40:28 +02:00
Jacob Schreiber 69994c0ba6 Responses changed to targets 2015-07-23 10:33:32 +02:00
Jacob Schreiber 6fedcabaf1 Verbosity reduced, suggestions merged 2015-07-23 10:31:52 +02:00