def dendrodata(): rows, cols, matrix = data.get_data('blogdata.txt') print "Calculating clusters...", tree = groups.cluster_dict(groups.cluster_hierarchy(matrix), rows) print " DONE." return {"tree": tree}
def blogdata(clustered=False): def dict_clusters(clust): count = dict(zip(cols, matrix[clust.id])) count.update({'Blog': rows[clust.id]}) return count rows, cols, matrix = data.get_data('blogdata.txt') if clustered: print "Calculating clusters...", clusters = groups.cluster_list(groups.cluster_hierarchy(matrix)) print " DONE." counts = map(dict_clusters, clusters) else: counts = [] for i, vector in enumerate(matrix): d = dict(zip(cols, vector)) d.update({'Blog': rows[i]}) counts.append(d) return {"cols": cols, "counts": counts}