MacroRankBasedEvaluator

class MacroRankBasedEvaluator(*, evaluation_factory=None, evaluation_triples=None, **kwargs)[source]

Bases: pykeen.evaluation.rank_based_evaluator.RankBasedEvaluator

Macro-average rank-based evaluation.

Initialize the evaluator.

Parameters
  • evaluation_factory (Optional[CoreTriplesFactory]) – the evaluation triples’ factory. Must be provided, if no explicit triples are provided.

  • evaluation_triples (Optional[LongTensor]) – the evaluation triples. If given, takes precedence over extracting triples from a factory.

  • kwargs – additional keyword-based parameters passed to RankBasedEvaluator.__init__().

Raises

ValueError – if neither evaluation triples nor a factory are provided

Attributes Summary

COLUMNS

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.

Attributes Documentation

COLUMNS = ('head', 'relation', 'tail')

Methods Documentation

finalize()[source]

Compute the final results, and clear buffers.

Return type

RankBasedMetricResults

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 target

  • scores (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

None