Tree.make_clusters

Make any given number of clusters, given a respective tree. [source]
Parameters:
k : array_like
  Number of clusters to be computed.

distance :
{'single','complete','average'} default = '.txt'
  The type of distance to be calculated.

leaf_dict :
dictionary
  Dictionary with all leaf node connections to their respective inner nodes.

inner_dict :
dictionary
  Dictionary with all inner node connections.

dm :
array_like
  Distance matrix saved in an numpy array.

leaf_labels :
array_like
  An array with all leaf labels.

processes :
int
  Number of processes to be used in the paralelization of this function.
get_cluster_label_dict : bool default = False
  If true, function outputs cluster_label_dict, which can be used to produce a color tree, with all clusters represented by different colors.
Returns:
cluster_labels : array_like
  A list with the cluster labels of every tree leaf.

cluster_label_dict :
dictionary
  A dictionary with leaf labels as keys and leaf labels as leafs.
See also:
tree.make_color_tree
 Make a color tree, given a list of cluster labels.

tree.make_tree
 Search for the best tree of a given distance matrix.

Example:

# Imports
from zgli.tree import make_clusters

# Make Clusters
cluster_labels, cluster_label_dict = make_clusters(5, 'complete', leaf_dict, inner_node_dict, dm, leaf_labels, 10, True)