RankBasedEvaluator
- class RankBasedEvaluator(filtered=True, metrics=None, metrics_kwargs=None, add_defaults=True, **kwargs)[source]
Bases:
pykeen.evaluation.evaluator.Evaluator
A rank-based evaluator for KGE models.
Initialize rank-based evaluator.
- Parameters
filtered (
bool
) – Whether to use the filtered evaluation protocol. If enabled, ranking another true triple higher than the currently considered one will not decrease the score.metrics (
Optional
[Sequence
[Union
[str
,RankBasedMetric
,Type
[RankBasedMetric
],None
]]]) – the rank-based metrics to computemetrics_kwargs (
Optional
[Mapping
[str
,Any
]]) – additional keyword parameteradd_defaults (
bool
) – whether to add all default metrics besides the ones specified by metrics / metrics_kwargs.kwargs – Additional keyword arguments that are passed to the base class.
Methods Summary
finalize
()Compute the final results, and clear buffers.
process_scores_
(hrt_batch, target, scores[, ...])Process a batch of triples with their computed scores for all entities.
Methods Documentation
- process_scores_(hrt_batch, target, scores, true_scores=None, dense_positive_mask=None)[source]
Process a batch of triples with their computed scores for all entities.
- Parameters
hrt_batch (
LongTensor
) – shape: (batch_size, 3)target (
Literal
[‘head’, ‘relation’, ‘tail’]) – the prediction targetscores (
FloatTensor
) – shape: (batch_size, num_entities)true_scores (
Optional
[FloatTensor
]) – shape: (batch_size, 1)dense_positive_mask (
Optional
[FloatTensor
]) – shape: (batch_size, num_entities) An optional binary (0/1) tensor indicating other true entities.
- Return type