def precision_at_k(vanilla_topk, fair_topk):
    """
    calculate precision @ K
    :param vanilla_topk: top K nodes in vanilla mining result
    :param fair_topk: top K nodes in debiased mining result
    :return: precision @ K
    """
    topk = set(fair_topk)
    groundtruth = set(vanilla_topk)
    return len(topk.intersection(groundtruth)) / len(topk)