in blink/candidate_retrieval/evaluator.py [0:0]
def candidate_generation_recall_at(self, ax=None, max_rank=None):
processed_mentions = self.data
total_num_of_docs = len(processed_mentions)
gold_positions = np.array(
[
mention["gold_pos"]
for mention in processed_mentions
if mention["gold_pos"] >= 0
]
)
if ax == None:
fig = plt.figure(figsize=(7, 7))
ax = plt.subplot(111)
ax.set_ylabel(str("Recall"))
ax.set_xlabel(str("True entity rank"))
rank_count_pairs = sorted(Counter(gold_positions).items(), key=lambda x: x[0])
# rank_count_pairs = rank_count_pairs[:k]
counts = [i[1] for i in rank_count_pairs]
recall = np.cumsum(counts) / total_num_of_docs * 100
rankings = [i[0] for i in rank_count_pairs]
if max_rank is not None:
for idx, rank in enumerate(rankings):
if rank > max_rank:
rankings = rankings[:idx]
recall = recall[:idx]
break
ax.plot(rankings, recall)