Skip to content

Commit b92c9ee

Browse files
committed
FIX remove unnecessary resize for update
1 parent b08b6cd commit b92c9ee

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

sklearn/tree/_tree.pyx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,6 @@ cdef class DepthFirstTreeBuilder(TreeBuilder):
268268
# check input
269269
X, y, sample_weight = self._check_input(X, y, sample_weight)
270270

271-
# Initial capacity
272-
cdef int init_capacity
273-
274-
if tree.max_depth <= 10:
275-
init_capacity = <int> (2 ** (tree.max_depth + 1)) - 1
276-
else:
277-
init_capacity = 2047
278-
279-
tree._resize(init_capacity)
280-
281271
# Parameters
282272
cdef Splitter splitter = self.splitter
283273
cdef SIZE_t max_depth = self.max_depth
@@ -286,10 +276,19 @@ cdef class DepthFirstTreeBuilder(TreeBuilder):
286276
cdef SIZE_t min_samples_split = self.min_samples_split
287277
cdef double min_impurity_decrease = self.min_impurity_decrease
288278

279+
# Initial capacity
280+
cdef int init_capacity
289281
cdef bint first = 0
290282
if self.initial_roots is None:
291283
# Recursive partition (without actual recursion)
292284
splitter.init(X, y, sample_weight, missing_values_in_feature_mask)
285+
286+
if tree.max_depth <= 10:
287+
init_capacity = <int> (2 ** (tree.max_depth + 1)) - 1
288+
else:
289+
init_capacity = 2047
290+
291+
tree._resize(init_capacity)
293292
first = 1
294293

295294
cdef SIZE_t start = 0

0 commit comments

Comments
 (0)