Beispiel #1
0
def get_all_combination_STEVE_best_graph(pred_labels_over_runs, performance_runs): ## steve's suggestions
    runs = list(pred_labels_over_runs.keys())
    meta_subgraphs = []
    for i in range(len(runs)-1):
        meta_subgraphs += list(combinations(runs, i+2))
    print ("len of meta subgraphs are ", len(meta_subgraphs))


    meta_graph_scores = []

    for meta_sub_graph1 in meta_subgraphs:
        current_subgraph_overlap = []
        current_subgraph_perf = []

        for ik1, rk1 in enumerate(meta_sub_graph1[:-1]):
            current_subgraph_perf.append(performance_runs[rk1])
            for rk2 in meta_sub_graph1[ik1+1:]:
                current_subgraph_overlap.append (float(calculate_overlap_labels(pred_labels_over_runs[rk1], pred_labels_over_runs[rk2]) ) )
        avg_score =  sum(current_subgraph_perf)/float(len(current_subgraph_perf))
        avg_overlap =  sum(current_subgraph_overlap)/float(len(current_subgraph_overlap))

        meta_graph_scores.append(avg_score/float(avg_overlap))  ## taking average of subgraph scores

    print ("the len of meta graph scores are : ", len(meta_graph_scores))
    best_sub_graph_index = meta_graph_scores.index(max(meta_graph_scores))
    print ("best subgraph is: ", meta_subgraphs[best_sub_graph_index], max(meta_graph_scores))

    return meta_subgraphs[best_sub_graph_index]
Beispiel #2
0
def get_complete_graph(pred_labels_over_runs,
                       performance_runs,
                       subgraph_size=4):
    runs = list(pred_labels_over_runs.keys())

    meta_subgraphs = list(combinations(runs, subgraph_size))
    print("len of meta subgraphs are ", len(meta_subgraphs))

    meta_graph_scores = []

    for meta_sub_graph1 in meta_subgraphs:
        current_subgraph_score = []
        for ik1, rk1 in enumerate(meta_sub_graph1[:-1]):
            for rk2 in meta_sub_graph1[ik1 + 1:]:
                current_subgraph_score.append(
                    performance_runs[rk1] * performance_runs[rk2] / float(
                        calculate_overlap_labels(pred_labels_over_runs[rk1],
                                                 pred_labels_over_runs[rk2])))
        meta_graph_scores.append(
            sum(current_subgraph_score) / float(len(current_subgraph_score)))

    print("the len of meta graph scores are : ", len(meta_graph_scores))
    best_sub_graph_index = meta_graph_scores.index(max(meta_graph_scores))
    print("best subgraph is: ", meta_subgraphs[best_sub_graph_index],
          max(meta_graph_scores))

    return meta_subgraphs[best_sub_graph_index]
Beispiel #3
0
def get_all_combination_best_graph(pred_labels_over_runs,
                                   performance_runs):  ## Edge based model
    runs = list(pred_labels_over_runs.keys())
    meta_subgraphs = []
    for i in range(len(runs) - 1):
        meta_subgraphs += list(combinations(runs, i + 2))
    print("len of meta subgraphs are ", len(meta_subgraphs))
    meta_graph_scores = []

    for meta_sub_graph1 in meta_subgraphs:
        current_subgraph_score = []
        for ik1, rk1 in enumerate(meta_sub_graph1[:-1]):
            for rk2 in meta_sub_graph1[ik1 + 1:]:
                current_subgraph_score.append(
                    performance_runs[rk1] + performance_runs[rk2] / float(
                        calculate_overlap_labels(pred_labels_over_runs[rk1],
                                                 pred_labels_over_runs[rk2])))
        meta_graph_scores.append(
            sum(current_subgraph_score) / float(len(current_subgraph_score))
        )  ## taking average of subgraph scores

    print("the len of meta graph scores are : ", len(meta_graph_scores))
    best_sub_graph_index = meta_graph_scores.index(max(meta_graph_scores))
    print("best subgraph is: ", meta_subgraphs[best_sub_graph_index],
          max(meta_graph_scores))

    return meta_subgraphs[best_sub_graph_index]
Beispiel #4
0
def get_node_pair_score(runs):

    for ik1, rk1 in enumerate(runs[:-1]):
        for rk2 in runs[ik1 + 1:]:
            meta_graph.update({
                rk1 + " " + rk2:
                calculate_overlap_labels(pred_labels_over_runs[rk1],
                                         pred_labels_over_runs[rk2])
            })
Beispiel #5
0
def get_all_combination_Vikas_EdgeAPPROACH_withCoverage_best_graph(
        pred_labels_over_runs, performance_runs, gold_labels):
    runs = list(pred_labels_over_runs.keys())
    meta_subgraphs = []
    for i in range(len(runs) - 1):
        meta_subgraphs += list(combinations(runs, i + 2))
    print("len of meta subgraphs are ", len(meta_subgraphs))
    meta_graph_scores = []
    meta_graph_coverage_scores = []

    for meta_sub_graph1 in meta_subgraphs:
        current_subgraph_score = []
        for ik1, rk1 in enumerate(meta_sub_graph1[:-1]):

            if ik1 == 0:  ## initializing the coverage list
                prediction_coverage = pred_labels_over_runs[rk1]

            for rk2 in meta_sub_graph1[ik1 + 1:]:
                current_subgraph_score.append(
                    performance_runs[rk1] + performance_runs[rk2] / float(
                        calculate_overlap_labels(pred_labels_over_runs[rk1],
                                                 pred_labels_over_runs[rk2])))
                prediction_coverage = get_union(prediction_coverage,
                                                pred_labels_over_runs[rk2])

        final_coverage = sum(get_intersection(
            prediction_coverage, gold_labels)) / float(sum(gold_labels))
        meta_graph_coverage_scores.append(final_coverage)
        meta_graph_scores.append(
            (sum(current_subgraph_score) / float(len(current_subgraph_score)))
            * final_coverage)  ## taking average of subgraph scores

    print("the len of meta graph scores are : ", len(meta_graph_scores))
    best_sub_graph_index = meta_graph_scores.index(max(meta_graph_scores))
    print("best subgraph is: ", meta_subgraphs[best_sub_graph_index],
          max(meta_graph_scores),
          meta_graph_coverage_scores[best_sub_graph_index])

    return meta_subgraphs[best_sub_graph_index]