TAMO.Clustering.Kmedoids
index
/home/David_Gordon/docs/TAMO/Clustering/Kmedoids.py

 
Modules
       
glob
pickle
random
string
sys

 
Functions
       
JumpWithinKMedoids_cluster(distanceMatrix, kmax=10, num_cycles=5, max_kMedoids_iterations=1000, min_dist=0.14999999999999999, seeds=None, verbose=0, print_fnctn=None, data=None)
(There are better choices)  Increases k over a range (1-kmax) and selects k for which
the change from k-1 "within_distance" is largest.
MinWithinKMedoids_cluster(distanceMatrix, k, num_cycles=5, max_kMedoids_iterations=1000, seeds=None, verbose=0, print_fnctn=None, data=None, return_WD=None)
Like original KMedoids_cluster, but the optimal iteration is picked based on 
having the minimum 'within distance', which is computed by the withinDist
function.
WD = SUM_clusters (SUM_motifs (SUM_inter_motif_distances)))
 
There is an optional flag to return WD to the parent, in case it wants to use it
decide whether to repeat with a different value of k, as in "JumpWithin"
averageList(lst)
bestKMedoids_cluster(distanceMatrix, kmax=10, num_cycles=5, max_kMedoids_iterations=1000, min_dist=0.14999999999999999, seeds=None, verbose=0, print_fnctn=None, data=None)
Descending k:  Stop Descending when distances between medoids becomes
larger than min_dist
bestaveKMedoids_cluster(distanceMatrix, kmax=10, num_cycles=5, max_kMedoids_iterations=1000, min_dist=0.14999999999999999, seeds=None, verbose=0, print_fnctn=None, data=None, kmin=0)
[Ben's Current pick 12-02-03]
Descending: Compute ave dist of members of a cluster to each of the other medoids.
If any average distances are too small (<min_dist), reduce k
bestupKMedoids_cluster(distanceMatrix, kmax=10, num_cycles=5, max_kMedoids_iterations=1000, min_dist=0.14999999999999999, seeds=None, verbose=0, print_fnctn=None, data=None)
Ascending (there are better choices)
Ascending version of "best", which looks for the point at which the
distances between medoids becomes too small
generate_random_1d(x=0, mult=1.0, n=100)
generate_random_2d(x=0, y=0, mult=1.0, n=100)
kMedoids_cluster(distanceMatrix, k, max_iterations=1000, seed='12345')
use kMedoid clustering
return a three-tuple:
        1.  k indices representing the medoids
        2.  k-lists of indices representing the clusters, 
        3. the average distance to the medoid in each cluster
metaKMedoids_cluster(distanceMatrix, k, num_cycles=5, max_kMedoids_iterations=1000, seeds=None, verbose=0, print_fnctn=None, data=None)
###NOTE CHANGED FROM Fraenkel.Clustering###
 
run kMedoid clustering num_cycles times
return a three-tuple:
        1.  k indices representing the medoids
        2.  k-lists of indices representing the clusters, 
        3. the average distance to the medoid in each cluster
if verbose =1 and a print function, print_fnctn, and the original data (not just the distance matrix) are supplied
the program will print out intermediate clustering results
metaminDiamKMedoids_cluster(distanceMatrix, kstart=1, num_cycles=5, max_kMedoids_iterations=1000, min_dist=0.14999999999999999, seeds=None, verbose=0, print_fnctn=None, data=None)
Ascending: increase k until the Diam (a.k.a. "distances") for each cluster are
smaller than min_dist
minDiamKMedoids_cluster(distanceMatrix, k, num_cycles=5, max_kMedoids_iterations=1000, seeds=None, verbose=0, print_fnctn=None, data=None)
print_Dmat(D)
print_list_clustering_results(clusters, data, avg_dist, k)
print_motif_clustering_results(clusters, data, avg_dist, k)
withinDist(clusters, data)