Package nltk :: Package cluster :: Module util :: Class Dendrogram
[hide private]
[frames] | no frames]

type Dendrogram

source code

object --+
         |
        Dendrogram

Represents a dendrogram, a tree with a specified branching order. This must be initialised with the leaf items, then iteratively call merge for each branch. This class constructs a tree representing the order of calls to the merge function.

Instance Methods [hide private]
 
__init__(self, items=[]) source code
 
merge(self, *indices)
Merges nodes at given indices in the dendrogram.
source code
 
groups(self, n)
Finds the n-groups of items (leaves) reachable from a cut at depth n.
source code
 
show(self, leaf_labels=[])
Print the dendrogram in ASCII art to standard out.
source code
 
__repr__(self) source code
Method Details [hide private]

__init__(self, items=[])
(Constructor)

source code 
Parameters:
  • items (sequence of (any)) - the items at the leaves of the dendrogram
Overrides: object.__init__

merge(self, *indices)

source code 

Merges nodes at given indices in the dendrogram. The nodes will be combined which then replaces the first node specified. All other nodes involved in the merge will be removed.

Parameters:
  • indices (seq of int) - indices of the items to merge (at least two)

groups(self, n)

source code 

Finds the n-groups of items (leaves) reachable from a cut at depth n.

Parameters:
  • n (int) - number of groups

show(self, leaf_labels=[])

source code 

Print the dendrogram in ASCII art to standard out.

Parameters:
  • leaf_labels (list) - an optional list of strings to use for labeling the leaves

__repr__(self)
(Representation operator)

source code 
Overrides: object.__repr__
(inherited documentation)