8000 fix the max_cardinality issue · scikit-learn/scikit-learn@710b3e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 710b3e1

Browse files
author
Lilian Weng
committed
fix the max_cardinality issue
1 parent 57672f2 commit 710b3e1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sklearn/tree/_tree.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ cdef class Tree:
11921192
cdef np.ndarray _get_categorical_value_mapping(self):
11931193
cdef SIZE_t i, node_id
11941194
cdef SIZE_t cardinality
1195-
cdef SIZE_t max_cardinality = <SIZE_t> _TREE_UNDEFINED
1195+
cdef SIZE_t max_cardinality = 0
11961196
cdef Node* node = NULL
11971197

11981198
# Get max cardinality
@@ -1217,4 +1217,4 @@ cdef class Tree:
12171217
for i in range(node.categorical_cardinality):
12181218
mappings[node_id, i] = node.categorical_value_mapping[i]
12191219

1220-
return mappings
1220+
return mappings

sklearn/tree/tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def fit(self, X, y, sample_weight=None, check_input=True,
313313
".shape = {})".format(X.shape,
314314
X_idx_sorted.shape))
315315

316-
if categorical_features is not None:
316+
if categorical_features:
317317
if max(categorical_features) >= self.n_features_:
318318
raise ValueError("Categorical feature indices are out of the "
319319
"range; there are only {} features.".format(

0 commit comments

Comments
 (0)
0