Skip to content

Commit f102bac

Browse files
committed
DOC copy comment describing hierarchical clustering children
1 parent 176c9ce commit f102bac

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

sklearn/cluster/_hierarchical.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ def _hc_get_descendent(int node, children, int n_leaves):
4141
The node for which we want the descendents.
4242
4343
children : list of pairs. Length of n_nodes
44-
List of the children of each nodes.
45-
This is not defined for leaves.
44+
The children of each non-leaf node. Values less than `n_samples` refer
45+
to leaves of the tree. A greater value `i` indicates a node with
46+
children `children[i - n_samples]`.
4647
4748
n_leaves : int
4849
Number of leaves.

sklearn/cluster/hierarchical.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ def ward_tree(X, connectivity=None, n_components=None, copy=True,
7070
Returns
7171
-------
7272
children : 2D array, shape (n_nodes, 2)
73-
list of the children of each nodes.
74-
Leaves of the tree have empty list of children.
73+
The children of each non-leaf node. Values less than `n_samples` refer
74+
to leaves of the tree. A greater value `i` indicates a node with
75+
children `children[i - n_samples]`.
7576
7677
n_components : sparse matrix.
7778
The number of connected components in the graph.
@@ -238,8 +239,9 @@ def _hc_cut(n_clusters, children, n_leaves):
238239
The number of clusters to form.
239240
240241
children : list of pairs. Length of n_nodes
241-
List of the children of each nodes.
242-
Leaves have empty list of children and are not stored.
242+
The children of each non-leaf node. Values less than `n_samples` refer
243+
to leaves of the tree. A greater value `i` indicates a node with
244+
children `children[i - n_samples]`.
243245
244246
n_leaves : int
245247
Number of leaves of the tree.

0 commit comments

Comments
 (0)