예제 #1
0
def calculate_probability_matrix(clustering):
    """
    """
    num_clusters = len(clustering.clusters)
    total_elements,cluster_sizes = clusTools.get_cluster_sizes(clustering.clusters) #@UnusedVariable
    class_list = clustering.gen_class_list()
    
    prob_matrix = []
    for i in range(num_clusters):
        row = [0.]*num_clusters
        prob_matrix.append(row)
    
    prob_increments = []
    for i in range(num_clusters):
        prob_increments.append(1./cluster_sizes[i])
    
    for i in range(len(class_list)-1):
        current_cluster = class_list[i]
        next_cluster = class_list[i+1]
        prob_matrix[current_cluster][next_cluster] += prob_increments[current_cluster]
    
    return prob_matrix
예제 #2
0
def calculate_probability_matrix(clustering):
    """
    """
    num_clusters = len(clustering.clusters)
    total_elements,cluster_sizes = clusTools.get_cluster_sizes(clustering.clusters) #@UnusedVariable
    class_list = clustering.gen_class_list()
    
    prob_matrix = []
    for i in range(num_clusters):
        row = [0.]*num_clusters
        prob_matrix.append(row)
    
    prob_increments = []
    for i in range(num_clusters):
        prob_increments.append(1./cluster_sizes[i])
    
    for i in range(len(class_list)-1):
        current_cluster = class_list[i]
        next_cluster = class_list[i+1]
        prob_matrix[current_cluster][next_cluster] += prob_increments[current_cluster]
    
    return prob_matrix
예제 #3
0
 def analysis_function_mean_cluster_size(self, clustering):
     """
     Returns the mean cluster size.
     """
     sizes = get_cluster_sizes(clustering.clusters)[1]
     return numpy.mean(sizes)
예제 #4
0
 def test_get_sizes(self):
     myclusters = []
     for c in test_data.clusters:
         myclusters.append(cluster_from_tuple(c))
     sizes = [5,4,4,4,3]
     numpy.testing.assert_array_equal(sizes, get_cluster_sizes(myclusters)[1], "Cluster sizes are different")
예제 #5
0
 def analysis_function_mean_cluster_size(self,clustering):
     """
     Returns the mean cluster size.
     """
     sizes = get_cluster_sizes(clustering.clusters)[1]
     return numpy.mean(sizes)