Commit Graph

88 Commits

Author SHA1 Message Date
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
Gilles Louppe ce0d52ea05 COSMITS + FIX to impurity_improvement 2013-11-29 14:02:21 +01:00
Peter Prettenhofer fda6211367 pass impurity to ``impurity_improvement`` - now it is correct so that arbitrary Criteria can be used in best-first search. 2013-11-29 10:56:57 +01:00
Peter Prettenhofer cde390f2c3 remove split_impurity from node_split signature 2013-11-22 17:47:21 +01:00
Peter Prettenhofer 5847be48a5 removed Impurity struct, Criterion.child_impurity now returns impurity_left and impurity_right (not total), fix: moved pos >= end check to if branch 2013-11-22 11:28:33 +01:00
Peter Prettenhofer 4b45668212 Best-first instead of branch heuristic - identical score as GBM on covertype 2013-11-21 13:43:54 +01:00
Peter Prettenhofer 13e43d202b Implement GBM's best-first heuristic tree growing procedure . 2013-11-20 21:10:16 +01:00
Peter Prettenhofer 5f09b5a419 tree code now supports both c-style and fortran inputs 2013-11-03 14:19:49 +02:00
Peter Prettenhofer e9cea77bd8 PriorityQueue for best-first tree growing
max_leaf_nodes instead of complete parameter
2013-11-03 09:40:24 +02:00
Peter Prettenhofer 1192fe64e5 Tree: compute partition specific impurity and total impurity in criterion.children_impurity. Pass partition impurity to stack to avoid re-computation (saves some runtime).
New tree parameter: complete; specifies whether complete binary trees are grows or if a greedy branch of max_depth is grown with at most max_depth + 1 leafs.
2013-11-02 01:04:23 +02:00
Olivier Grisel f859b7d3fa Release the GIL at tree building time 2013-10-16 16:26:57 +02:00
Gilles Louppe 6a5a65dede ENH: use npy_int32 type 2013-10-09 13:36:02 +02:00
Gilles Louppe b9384c98cb ENH: make node_reset/split/value gil-free 2013-10-09 13:35:52 +02:00
Gilles Louppe dc36bf3dc0 FIX: random number generator
FIX: address @larsmans + @ogrisel comments

ENH: add INT32_t type

ENH: rename INT32_t to UINT32_t

FIX: modulo RAND_R_MAX+1

FIX: broken tests
2013-09-22 19:35:18 +02:00
Gilles Louppe 69f49b1532 FIX: release reference to X in _tree.splitter 2013-08-13 22:58:10 +02:00
Gilles Louppe 20f5985d68 DOC: some documentation for the Tree Cython structure 2013-07-25 09:40:26 +02:00