8000 Merge branch 'scarliles/update-node-refactor2' into scarliles/update-… · ssec-jhu/scikit-learn@c7b675b · GitHub
[go: up one dir, main page]

Skip to content

Commit c7b675b

Browse files
Merge branch 'scarliles/update-node-refactor2' into scarliles/update-node-refactor3
2 parents 6c117a2 + 87c90fd commit c7b675b

File tree

2 files changed

+301
-216
lines changed

2 files changed

+301
-216
lines changed

sklearn/tree/_tree.pxd

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,81 @@ cdef struct ParentInfo:
4343
float64_t impurity # the impurity of the parent
4444
intp_t n_constant_features # the number of constant features found in parent
4545

46+
ctypedef intp_t (*AddOrUpdateNodeFunc)(
47+
Tree tree,
48+
intp_t parent,
49+
bint is_left,
50+
bint is_leaf,
51+
SplitRecord* split_node,
52+
float64_t impurity,
53+
intp_t n_node_samples,
54+
float64_t weighted_n_node_samples,
55+
unsigned char missing_go_to_left
56+
) except -1 nogil
57+
58+
# A record on the stack for depth-first tree growing
59+
cdef struct StackRecord:
60+
intp_t start
61+
intp_t end
62+
intp_t depth
63+
intp_t parent
64+
bint is_left
65+
float64_t impurity
66+
intp_t n_constant_features
67+
float64_t lower_bound
68+
float64_t upper_bound
69+
70+
cdef extern from "<stack>" namespace "std" nogil:
71+
cdef cppclass stack[T]:
72+
ctypedef T value_type
73+
stack() except +
74+
bint empty()
75+
void pop()
76+
void push(T&) except + # Raise c++ exception for bad_alloc -> MemoryError
77+
T& top()
78+
79+
cdef struct BuildEnv:
80+
# Parameters
81+
intp_t max_depth
82+
intp_t min_samples_leaf
83+
float64_t min_weight_leaf
84+
intp_t min_samples_split
85+
float64_t min_impurity_decrease
86+
87+
unsigned char store_leaf_values
88+
89+
# Initial capacity
90+
intp_t init_capacity
91+
bint first
92+
93+
intp_t start
94+
intp_t end
95+
intp_t depth
96+
intp_t parent
97+
bint is_left
98+
intp_t n_node_samples
99+
float64_t weighted_n_node_samples
100+
intp_t node_id
101+
float64_t right_child_min, left_child_min, right_child_max, left_child_max
102+
103+
SplitRecord* split_ptr
104+
105+
float64_t middle_value
106+
bint is_leaf
107+
intp_t max_depth_seen
108+
109+
intp_t rc
110+
111+
stack[StackRecord] builder_stack
112+
stack[StackRecord] update_stack
113+
stack[StackRecord]* target_stack
114+
StackRecord stack_record
115+
116+
ParentInfo parent_record
117+
118+
AddOrUpdateNodeFunc add_or_update_node
119+
120+
46121
cdef class BaseTree:
47122

48123
# Inner structures: values are stored separately from node structure,

0 commit comments

Comments
 (0)
0