Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ New features
Enhancements
............

- Edited criterion for leaf nodes in decision tree criterion by declaring a
node as a leaf if the weighted number of samples at the node is less than
2 * the minimum weight specified to be at a node. This makes growth more
efficient, but trees using parameters that modify the weight at each leaf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a confusing way of stating it. Will fix it up in master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @jnothman

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be grown differently. (`#7441
<https://github.com/scikit-learn/scikit-learn/pull/7441>`_) by `Nelson
Liu`_.

Bug fixes
.........
Expand Down
18 changes: 9 additions & 9 deletions sklearn/tree/_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ cdef class DepthFirstTreeBuilder(TreeBuilder):
n_node_samples = end - start
splitter.node_reset(start, end, &weighted_n_node_samples)

is_leaf = ((depth >= max_depth) or
(n_node_samples < min_samples_split) or
(n_node_samples < 2 * min_samples_leaf) or
(weighted_n_node_samples < min_weight_leaf))
is_leaf = (depth >= max_depth or
n_node_samples < min_samples_split or
n_node_samples < 2 * min_samples_leaf or
weighted_n_node_samples < 2 * min_weight_leaf)

if first:
impurity = splitter.node_impurity()
Expand Down Expand Up @@ -436,11 +436,11 @@ cdef class BestFirstTreeBuilder(TreeBuilder):
impurity = splitter.node_impurity()

n_node_samples = end - start
is_leaf = ((depth > self.max_depth) or
(n_node_samples < self.min_samples_split) or
(n_node_samples < 2 * self.min_samples_leaf) or
(weighted_n_node_samples < self.min_weight_leaf) or
(impurity <= min_impurity_split))
is_leaf = (depth > self.max_depth or
n_node_samples < self.min_samples_split or
n_node_samples < 2 * self.min_samples_leaf or
weighted_n_node_samples < 2 * self.min_weight_leaf or
impurity <= min_impurity_split)

if not is_leaf:
splitter.node_split(impurity, &split, &n_constant_features)
Expand Down