8000 MNT Refactor tree splitter to use memoryviews (#23273) · scikit-learn/scikit-learn@ad5936f · GitHub
[go: up one dir, main page]

Skip to content

Commit ad5936f

Browse files
committed
MNT Refactor tree splitter to use memoryviews (#23273)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent 92e6ec5 commit ad5936f

File tree

3 files changed

+105
-140
lines changed

3 files changed

+105
-140
lines changed

doc/whats_new/v1.2.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ Changelog
6565
now conducts validation for `max_features` and `feature_names_in` parameters.
6666
:pr:`23299` by :user:`Long Bao <lorentzbao>`.
6767

68+
:mod:`sklearn.tree`
69+
...................
70+
71+
- |Fix| Fixed invalid memory access bug during fit in
72+
:class:`tree.DecisionTreeRegressor` and :class:`tree.DecisionTreeClassifier`.
73+
:pr:`23273` by `Thomas Fan`_.
74+
6875
Code and Documentation Contributors
6976
-----------------------------------
7077

sklearn/tree/_splitter.pxd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ cdef class Splitter:
4646
cdef object random_state # Random state
4747
cdef UINT32_t rand_r_state # sklearn_rand_r random number state
4848

49-
cdef SIZE_t* samples # Sample indices in X, y
49+
cdef SIZE_t[::1] samples # Sample indices in X, y
5050
cdef SIZE_t n_samples # X.shape[0]
5151
cdef double weighted_n_samples # Weighted number of samples
52-
cdef SIZE_t* features # Feature indices in X
53-
cdef SIZE_t* constant_features # Constant features indices
52+
cdef SIZE_t[::1] features # Feature indices in X
53+
cdef SIZE_t[::1] constant_features # Constant features indices
5454
cdef SIZE_t n_features # X.shape[1]
55-
cdef DTYPE_t* feature_values # temp. array holding feature values
55+
cdef DTYPE_t[::1] feature_values # temp. array holding feature values
5656

5757
cdef SIZE_t start # Start position for the current node
5858
cdef SIZE_t end # End position for the current node

0 commit comments

Comments
 (0)
0