f4beaac559e00a3676d942dc7e8fea69efc01cfe,catalyst/metrics/ndcg.py,,ndcg,#Any#Any#Any#Any#,72

Before Change


    ndcg_k_tuple = ()
    for k in top_k:
        ideal_dcgs = dcg(targets, targets, k, gain_function)
        predicted_dcgs = dcg(outputs, targets, k, gain_function)
        ndcg_score = predicted_dcgs / ideal_dcgs
        idcg_mask = ideal_dcgs == 0
        ndcg_score[idcg_mask] = 0.0
        ndcg_k_tuple += (ndcg_score,)

After Change


    results = []
    for k in topk:
        ideal_dcgs = dcg(targets, targets, gain_function)[:, :k]
        predicted_dcgs = dcg(outputs, targets, gain_function)[:, :k]
        ideal_dcgs_score = torch.sum(ideal_dcgs, dim=1)
        predicted_dcgs_score = torch.sum(predicted_dcgs, dim=1)
        ndcg_score = predicted_dcgs_score / ideal_dcgs_score
        idcg_mask = ideal_dcgs_score == 0
        ndcg_score[idcg_mask] = 0.0
        results.append(torch.mean(ndcg_score))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 4

Instances


Project Name: Scitator/catalyst
Commit Name: f4beaac559e00a3676d942dc7e8fea69efc01cfe
Time: 2020-11-30
Author: raveforlive@gmail.com
File Name: catalyst/metrics/ndcg.py
Class Name:
Method Name: ndcg


Project Name: catalyst-team/catalyst
Commit Name: f4beaac559e00a3676d942dc7e8fea69efc01cfe
Time: 2020-11-30
Author: raveforlive@gmail.com
File Name: catalyst/metrics/ndcg.py
Class Name:
Method Name: ndcg


Project Name: catalyst-team/catalyst
Commit Name: f4beaac559e00a3676d942dc7e8fea69efc01cfe
Time: 2020-11-30
Author: raveforlive@gmail.com
File Name: catalyst/metrics/tests/test_ndcg.py
Class Name:
Method Name: test_dcg