Skip to content

Commit f1a780e

Browse files
author
[zebinyang]
committed
fix a bug in CART Regressor and Classifier (sum_left update should be executed before checking min_samples_leaf); version 0.2.3
1 parent 254f334 commit f1a780e

File tree

2 files changed

+19
-88
lines changed

2 files changed

+19
-88
lines changed

examples/demo.ipynb

Lines changed: 18 additions & 87 deletions
Large diffs are not rendered by default.

simtree/cart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ def node_split(self, sample_indice):
133133
sum_total = np.sum(node_y)
134134
for i, _ in enumerate(sortted_indice):
135135

136+
sum_left += node_y[sortted_indice[i]]
136137
if ((i + 1) < self.min_samples_leaf) or ((n_samples - i - 1) < self.min_samples_leaf):
137138
continue
138139

139140
n_left = i + 1
140141
n_right = n_samples - i - 1
141-
sum_left += node_y[sortted_indice[i]]
142142

143143
left_impurity = 0
144144
right_impurity = 0

0 commit comments

Comments
 (0)