def visualize_col(): """ """ adj_matrix = col_matrix(col_k, nnc_mps, agreement_matrix, nnc_arbit, mps) classes = get_equiv_classes(nnc_mps, agreement_matrix, nnc_arbit, mps) classes_set = set(classes) classes_set.remove(-1) num_classes = len(classes_set) classes_ord = list(classes_set) classes_ord.sort() class_indices = {classes_ord[i]: i for i in range(num_classes)} class_sizes = [classes.count(cls) for cls in classes_ord] groups = [None for i in range(len(classes))] for i in range(len(classes_ord)): class_index = i rel_p = [mp[1][0] for mp in mps if classes[mps.index(mp)] == classes_ord[class_index]] counts = [rel_p.count(rel_p[j]) for j in range(len(rel_p))] dominant = rel_p[counts.index(max(counts))] groups[i] = dominant names = [str(i) for i in range(len(adj_matrix))] #groups = [str(i) for i in range(len(adj_matrix))] write_json_graph_general(adj_matrix, names, groups, filename = "viz/col/" + agr_method + '_' + str(start_session) + '_' + str(end_session) + 'minsess' + str(min_sessions) + '_' + 'k=' + str(col_k) + '_' + str(nnc_arbit) + ".json")
def visualize_sen_avg(): """ """ adj_matrix = col_matrix(col_k, sen_nnc_mps, sen_agreement_matrix, nnc_arbit, sen_mps) classes = get_equiv_classes(sen_nnc_mps, sen_agreement_matrix, nnc_arbit, sen_mps) classes_set = set(classes) classes_set = [thing for thing in classes_set if thing != -1] num_classes = len(classes_set) classes_ord = list(classes_set) classes_ord.sort() class_indices = {classes_ord[i]: i for i in range(num_classes)} class_sizes = [classes.count(cls) for cls in classes_ord] groups = [None for i in range(len(classes))] for i in range(len(classes_ord)): class_index = i rel_p = [mp[1][0] for mp in sen_mps if classes[sen_mps.index(mp)] == classes_ord[class_index]] counts = [rel_p.count(rel_p[j]) for j in range(len(rel_p))] dominant = rel_p[counts.index(max(counts))] groups[i] = dominant names = [str(classes.count(classes_ord[i])) for i in range(len(adj_matrix))] #groups = [str(i) for i in range(len(adj_matrix))] lis = [] for row in adj_matrix: lis += row lis = [thing for thing in lis if thing != 0] average = float(sum(lis))/len(lis) for i in range(len(adj_matrix)): for j in range(len(adj_matrix)): if adj_matrix[i][j] < average: adj_matrix[i][j] = 0 else: adj_matrix[i][j] = 1 write_json_graph_general(adj_matrix, names, groups, filename = "viz/col/sen" + str(sen_n) + agr_method + '_' + str(sen_start_session) + '_' + str(sen_end_session) + 'minsess' + str(sen_min_sessions) + '_' + 'k=' + str(col_k) + '_' + str(nnc_arbit) + "avg.json")