Commit Graph

436 Commits

Author SHA1 Message Date
Loïc Estève caeb09e866
FIX Make decision tree pickles deterministic (#27580)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
2023-10-17 14:25:17 +02:00
Adam Li 210550007e
MAINT Replace double with float64_t inside tree submodule (#27539)
Signed-off-by: Adam Li <adam2392@gmail.com>
2023-10-06 22:49:16 +02:00
Adam Li fb0ab5abca
MAINT Fix ctypedef types in tree submodule (#27352)
Signed-off-by: Adam Li <adam2392@gmail.com>
2023-10-05 12:47:11 -04:00
Adam Li 4fcbbc01be
[DOC] Improve tree documentation (#26592) 2023-08-29 16:10:43 +05:00
Julien Jerphanion dfd299b19e
MAINT Remove soon-to-be deprecated scipy.sparse functions (#26751) 2023-07-12 18:34:01 +02:00
Loïc Estève 77d4bc1085
MNT Put nogil at the end of function signature (#26785) 2023-07-06 14:36:49 +00:00
Samuel O. Ronsin b88b53985d
ENH Monotonic Contraints for Tree-based models (#13649)
Co-authored-by: Pat O'Reilly <patrick.oreilly256@gmail.com>
Co-authored-by: dsleo <leooleds@gmail.com>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
2023-07-01 13:46:12 +02:00
Thomas J. Fan 15f7cfbc05
CLN Renames missing_values_in_feature_mask (#26580) 2023-06-14 16:50:04 +00:00
Julien Jerphanion 41b0bd82ff
MAINT Use `scipy.sparse.isspmatrix_*` (#26420) 2023-05-30 13:46:32 -04:00
Adam Li 58f0f1d6fb
MAINT Fix usage of `property` in Cython extension classes (#26297) 2023-05-09 15:13:24 +02:00
Thomas J. Fan 6392148d80
ENH Adds missing value support for trees (#23595)
Co-authored-by: Tim Head <betatim@gmail.com>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
2023-05-04 10:19:24 +02:00
Jérémie du Boisberranger 9cb1111028
MAINT Cython linting (#25861) 2023-04-19 14:32:53 +00:00
Adam Li dfe9e2e118
MAINT Remove Cython compilation warnings ahead of Cython3.0 release (#25621) 2023-02-19 18:14:56 +01:00
Omar Salman 872a084168
FIX error when deserialzing a Tree instance from a read only buffer (#25585) 2023-02-13 18:42:47 +01:00
Omar Salman 584d413fec
MAINT Replace cnp.ndarray with memory views in sklearn.tree._tree (where possible) (#25540) 2023-02-09 08:21:28 +00:00
Omar Salman 2620a5545a
MAINT Remove -Wsign-compare warnings when compiling sklearn.tree._tree (#25507) 2023-02-01 17:28:12 +01:00
Felipe Siola 99562100e9
EFF Improve IsolationForest predict time (#25186)
Co-authored-by: Felipe Breve Siola <felipe.breve-siola@klarna.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Tim Head <betatim@gmail.com>
2023-01-24 15:03:13 +00:00
Loïc Estève f5ae73dcb4
CI Use latest Cython sources in scipy-dev build (#25300) 2023-01-11 13:55:13 -05:00
Adam Li 9268eea91f
MAINT Handle `Tree.sample_weight` using a memoryview (#24994)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Fixes https://github.com/scikit-learn/scikit-learn/issues/24987
2022-11-22 20:04:07 +01:00
Marco Edward Gorelli 2f65ac764b
MAINT clean-up unused variables and imports in cython files (#24347) 2022-09-05 10:39:20 +02:00
Rocco Meli 3850935ea6
MNT Use cimport numpy as cnp for sklearn/tree (#23315)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
2022-05-14 16:04:01 -04:00
Tom McTiernan 4e663bdd21
DOC Fix return type of weighted_n_node_samples (#23284) 2022-05-05 09:47:21 -04:00
zhenfisher b2c67afbd2
DOC Fixes grammar in decision tree's cpp pruning docstring (#20442)
Co-authored-by: zhenfisher <>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
2022-04-23 15:59:47 -04:00
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