Skip to content

Using RankBasedEvaluator directly on a ranking #1355

Answered by mberr
romy-vos asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can directly use the RankBasedEvaluator instance to process scores, e.g.:

import torch

from pykeen.evaluation import RankBasedEvaluator
from pykeen.datasets import get_dataset
from pykeen.typing import LABEL_TAIL

# instantiate an evaluator
evaluator = RankBasedEvaluator()

# process the scores
# todo: replace this by your way how to calculate scores
dataset = get_dataset(dataset="nations")
for hrt_batch in dataset.training.mapped_triples.split(16, dim=0):
    scores = torch.rand(size=(hrt_batch.shape[0], dataset.num_entities))
    true_score = torch.gather(scores, dim=-1, index=hrt_batch[:, 2:3])
    evaluator.process_scores_(hrt_batch=hrt_batch, target=LABEL_TAIL, scores=scores, 

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@romy-vos
Comment options

@yaaani85
Comment options

@mberr
Comment options

Answer selected by romy-vos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants