def get_statistics(alignment_matrix, groundtruth, groundtruth_matrix=None, use_greedy_match=False, get_all_metric=False): if use_greedy_match: print("This is greedy match accuracy") pred = greedy_match(alignment_matrix) else: pred = get_nn_alignment_matrix(alignment_matrix) acc = compute_accuracy(pred, groundtruth) if get_all_metric: MAP, Hit, AUC = compute_MAP_Hit_AUC(alignment_matrix, groundtruth) pred_top_5 = top_k(alignment_matrix, 5) precision_5 = compute_precision_k(pred_top_5, groundtruth) pred_top_10 = top_k(alignment_matrix, 10) precision_10 = compute_precision_k(pred_top_10, groundtruth) pred_top_20 = top_k(alignment_matrix, 20) precision_20 = compute_precision_k(pred_top_20, groundtruth) pred_top_30 = top_k(alignment_matrix, 30) precision_30 = compute_precision_k(pred_top_30, groundtruth) pred_top_50 = top_k(alignment_matrix, 50) precision_50 = compute_precision_k(pred_top_50, groundtruth) pred_top_100 = top_k(alignment_matrix, 100) precision_100 = compute_precision_k(pred_top_100, groundtruth) return acc, MAP, Hit, AUC, precision_5, precision_10, precision_20, precision_30, precision_50, precision_100 return acc
# compute the approximate closed-form solution s = (1 - alpha) * h + D * N * np.dot( U, np.linalg.lstsq(Lambda, np.dot(U.T, x), rcond=-1)[0]) S = s.reshape((n1, n2)) return S if __name__ == "__main__": args = parse_args() print(args) data1 = Dataset(args.prefix1) data2 = Dataset(args.prefix2) A1 = data1.adjacency # (3096x3096) A2 = data2.adjacency # (1118x1118) N1 = data1.features # (3096x538) N2 = data2.features # (1118x538) groundtruth = load_groundtruth(args.groundtruth) H = get_H(args.H, data1, data2) # (1118, 3096) S = FINAL_NFLOW(A1, A2, N1, N2, H, args.alpha, args.r) matched = get_top_k(S, data1.id2idx, data2.id2idx, k=args.k) acc = compute_accuracy(matched, groundtruth) print("Top-k accuracy (%d pairs): %.2f%%" % (len(matched.items()), acc)) matched = greedy_match(S, data1.id2idx, data2.id2idx) acc = compute_accuracy(matched, groundtruth) print("Greedy match accuracy (%d pairs): %.2f%%" % (len(matched.items()), acc))
def get_statistics(alignment_matrix, groundtruth_matrix): pred = greedy_match(alignment_matrix) greedy_match_acc = compute_accuracy(pred, groundtruth_matrix) print("Accuracy: %.4f" % greedy_match_acc)