f4beaac559e00a3676d942dc7e8fea69efc01cfe,catalyst/metrics/hitrate.py,,hitrate,#Any#Any#Any#,8
Before Change
k = min(outputs.size(1), k)
_, indices_for_sort = outputs.sort(descending=True, dim=-1)
true_sorted_by_preds = torch.gather(
targets, dim=-1, index=indices_for_sort
)
true_sorted_by_pred_shrink = true_sorted_by_preds[:, :k]
After Change
results = []
targets_sort_by_outputs = process_recsys_components(outputs, targets)
for k in topk:
k = min(outputs.size(1), k)
hits_score = torch.sum(targets_sort_by_outputs[:, :k], dim=1) / k
results.append(torch.mean(hits_score))
return results
__all__ = ["hitrate"]
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/hitrate.py
Class Name:
Method Name: hitrate
Project Name: brian-team/brian2
Commit Name: bb0b34fe488fc125fcd8cbb367db92212ac988b3
Time: 2013-03-26
Author: marcel.stimberg@ens.fr
File Name: brian2/stateupdaters/base.py
Class Name: StateUpdateMethod
Method Name: determine_stateupdater
Project Name: kmike/pymorphy2
Commit Name: 837b2efde71507b09033c3ea6f2502e2306f8eef
Time: 2013-02-18
Author: kmike84@gmail.com
File Name: pymorphy2/analyzer.py
Class Name: MorphAnalyzer
Method Name: _parse_as_word_with_known_suffix