Commit Graph

103 Commits

Author SHA1 Message Date
Jérémie du Boisberranger ef71c8597e
MNT Clean deprecations for 1.0 | trees (#19336) 2021-06-15 18:18:47 +02:00
Haoyin Xu 4023a0f94b
CLN Fix _add_node parameter name (#20008) 2021-04-29 16:38:53 -07:00
Juan Carlos Alfaro Jiménez e4ebcbcafd
MNT Deprecate X_idx_sorted in tree module (#17614) 2020-06-17 13:58:47 -04: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
(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
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
Nelson Liu d2aaf0f4bb doc: fix spellings of 'license' 2016-03-31 17:25:31 -07: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 44d81a0ec3 FIX: add except* in Splitter.init definitions 2015-02-23 08:19:10 +01:00
Arnaud Joly c03c01a504 ENH Bring sparse input support to tree-based methods
Author:     Arnaud Joly <arnaud.v.joly@gmail.com>
            Fares Hedayati <fares.hedayati@gmail.com>
2014-11-06 13:58:28 +01:00
Lars Buitinck 5335539d95 FIX propagate MemoryError from Tree._resize
Fixes #3684. "except *" declaration was ignored because it was missing
from the .pxd file.
2014-09-22 14:22:46 +02:00
Noel Dawe 72b3da8302 tree: use min_weight_leaf internally while exposing min_weight_fraction_leaf 2014-07-02 11:47:32 +02:00
Noel Dawe 7e9c093585 tree: add min_weight_fraction_leaf 2014-07-02 11:47:31 +02:00
Joel Nothman 10507dcaa5 COSMIT factor out split data as struct 2014-06-22 23:55:38 -04:00
Gilles Louppe 7ce38f4405 ENH: better API for passing weighted_n_samples 2014-04-12 13:36:16 +02:00
Gilles Louppe 45c0f046d0 ENH: rename normalizer -> weighted_n_samples 2014-04-12 13:25:35 +02:00
Gilles Louppe 57a743a157 ENH: rename Node attributes to avoid confusion 2014-04-12 11:06:57 +02:00
Gilles Louppe 698eafa4ed DOC: better doc for impurity_improvement 2014-04-12 10:38:42 +02:00
Gilles Louppe 61dd4b4be9 FIX: weight impurity improvement by the size of the node 2014-04-12 10:33:04 +02:00
Gilles Louppe d40eeb0823 DOC: wordings 2014-03-22 17:41:33 +01:00
Arnaud Joly d774953ed8 DOC missing words 2014-03-21 15:53:01 +01:00
Arnaud Joly a4680b1268 DOC document internal tree class 2014-03-21 15:34:31 +01:00
Arnaud Joly 3a6b8340d6 Add space to be consistent with _tree.pyx 2014-03-21 14:38:54 +01:00
Arnaud Joly 5839ddaca4 DOC document max_depth of TreeBuilder 2014-03-20 14:20:35 +01:00
Arnaud Joly 2c82c8adf0 FIX tons of flake8 2014-03-20 14:20:35 +01:00
Arnaud Joly 9d728f3f7d ENH stricter separation between splitter and criterion 2014-03-20 14:20:35 +01:00
Arnaud Joly 39a2a76a2f ENH stricter separation between tree builder, splitter and criterion 2014-03-20 14:20:35 +01:00
Arnaud Joly 8f6b75375a ENH for the tree structure max_depth is part of the inner structure 2014-03-20 14:20:35 +01:00
Arnaud Joly 07d6e8d926 ENH clean public tree strucure 2014-03-20 14:20:34 +01:00
Arnaud Joly e22045a670 ENH avoid serializing the splitter & criterion + avoid storing tree parameter in the tree structure 2014-03-20 14:20:34 +01:00
Arnaud Joly f434c8cb84 Clean tree builder interface 2014-03-20 14:20:34 +01:00
Arnaud Joly 57f73f16c5 DOC more comments about features and constant_features 2014-03-10 14:00:33 +01:00
Arnaud Joly c49294c392 DOC verbose documentation of features and constant_features 2014-03-10 12:17:52 +01:00
Arnaud Joly 3e123a1b7f WIP add constant_features array 2014-03-10 12:16:09 +01:00
Arnaud Joly abaf100a65 WIP add n_constant_features argument 2014-03-10 12:15:58 +01:00
Gilles Louppe 4ebf883c38 FIX: Weight impurity decreases with weighted_n_samples 2014-02-06 19:01:32 +01:00
eltermann 60e32899ef Fixed documentation on sklearn/tree 2014-01-29 13:32:33 -02:00
Lars Buitinck 7c33502c2e ENH faster heapsort in trees
Uses the heapsort version that I'm familiar with: linear-time heapify
followed by n delete-min operations. Also cache-friendlier by copying
active features into a temporary array.

Random forest training time on covertype:
now     34.4123s
before  60.1179s
2014-01-25 15:13:01 +01:00
Joel Nothman 87194f77cb Remove 'locked', add comments 2014-01-25 22:10:18 +11:00
Joel Nothman 86fbebdadf FIX dtype refcount; block resizing after building 2014-01-24 09:30:06 +11:00
Joel Nothman e53263988a FIX remove reference cycles from Tree 2014-01-24 07:54:01 +11:00
Joel Nothman e7e7133912 ENH/FIX Change Tree underlying data structure
* avoid segfault (#2726) by setting base on numpy arrays
* A struct array for tree nodes and values array (size indeterminate at
compile time) are the only underlying structure, so each node is locally
grouped memory, and joblib dumps will save only two numpy files per
tree.
* predict() uses the value array's take method, reducing code repetition
2014-01-16 09:32:16 +11:00
Lars Buitinck 7fc52ffdb4 BUG fix unchecked mallocs in trees
All mallocs should be checked now. Some notes for the next person to touch
this code, or do anything with malloc in Cython code:

* with gil: raise MemoryError() didn't work as expected, as a surrounding
  nogil block catches and logs the exception, then proceeds as if nothing
  happened.
* There were several opportunities for double free in the code. This is
  handled by letting the destructor handle the freeing.
* Similarly, constructors failed to set pointers to NULL so __dealloc__
  would try to free unitialized pointers.
* Out of memory might leave trees in an inconsistent state, but will not
  cause a double free. A subsequent successful fit should produce a
  consistent state, although I didn't test this.
* Replaced a free/calloc with a realloc; realloc(NULL, n) = malloc(n).
* free(NULL) is a harmless no-op per ISO C89.

Also performed an optimization: the pre-sort splitter was using size_t for
an array of booleans. unsigned char is faster and smaller.

Finally, fixed some cosmetic issues (long lines).
2014-01-11 15:44:44 +01:00