def main(results_fpath, test_fpath):
    lamb = 1.0
    probs, users, objs = read_results(results_fpath, lamb)
    rrs = []
    with open(test_fpath) as test_file:
        for line in test_file:
            spl = line.strip().split()
            user = spl[0]
            if user not in users:
                continue

            for o in spl[1:]:
                rr = 1.0
                for v, c in probs[user]:
                    if c == o:
                        break
                    else:
                        rr += 1
                rr = 1.0 / rr
                rrs.append(rr)
    print(sum(rrs) / len(rrs))
dataset/ETHPy150Open flaviovdf/tribeflow/scripts/mrr_stages.py/main/original