Algorithm::Cluster::Thresh - Adds thresholding to hierarchical clustering of Algorithm::Cluster
use Algorithm::Cluster::Thresh; # Assuming you have a lower diagonal distance matrix ... # See L<Algorithm::Cluster> and / or L<Algorithm::DistanceMatrix> my $distmatrix; use Algorithm::Cluster qw/treecluster/; my $tree = treecluster(data=>$distmatrix, method=>'a'); # 'a'verage linkage # Get your objects and the cluster IDs they belong to # Clusters are within 5.5 of each other (based on average linkage here) my $cluster_ids = $tree->cutthresh(5.5); # Index corresponds to that of the original objects print 'Object 2 belongs to cluster number ', $cluster_ids->, "\n";
This is a small helper package for Algorithm::Cluster, but not an official part of it. That manual can be found here:
This package adds a simple method
$tree-cutthresh(5.5)> to permit clustering by thresholds, rather than by needing to pre-define the number of clusters to be created.
This is a Pure Perl module. It's not as efficient as the XS approach, which has already been submitted as a patch:
In the meantime, this module provides a Pure Perl implementation.
Algorithm::Cluster::Thresh - Hierarchical clustering with variable thresholds
Returns an array, where the value of each array element is the integer cluster ID of that object.
Returns a reference to the array in scalar context.
Chad A. Davis <email@example.com>
This software is copyright (c) 2011 by Chad A. Davis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.