In the custom_metrics.py file, top_accuracy function:
you write:
top_hits[query_id] = sorted(doc_scores.keys(), key=lambda item: item[1], reverse=True)[0:k_max]
but I think that you should instead wrote [elem[0] for elem in
sorted(doc_scores.items(), key=lambda item: item[1], reverse=True)[0:k_max]]
indeed, in your code, you are sorting by the key and not by the score
In the custom_metrics.py file, top_accuracy function: you write: top_hits[query_id] = sorted(doc_scores.keys(), key=lambda item: item[1], reverse=True)[0:k_max] but I think that you should instead wrote [elem[0] for elem in sorted(doc_scores.items(), key=lambda item: item[1], reverse=True)[0:k_max]] indeed, in your code, you are sorting by the key and not by the score