LCWAInstances

class LCWAInstances(*, pairs: ndarray, compressed: csr_matrix, target: Literal[0, 1, 2] | Literal['head', 'relation', 'tail'] | None = None, loss_weighter: str | LossWeighter | type[LossWeighter] | None = None, loss_weighter_kwargs: Mapping[str, Any] | None = None)[source]

Bases: Instances[LCWABatch]

Triples and mappings to their indices for LCWA.

Initialize the LCWA instances.

Parameters:
  • pairs (np.ndarray) – The unique pairs

  • compressed (scipy.sparse.csr_matrix) – The compressed triples in CSR format

  • target (TargetHint) – The prediction target.

  • loss_weighter (HintOrType[LossWeighter]) – The method to determine sample weights.

  • loss_weighter_kwargs (OptionalKwargs) – Parameters for the method to determine sample weights.

Note

The parameter pair (loss_weighter, loss_weighter_kwargs) is used for pykeen.triples.weights.loss_weighter_resolver

An explanation of resolvers and how to use them is given in https://class-resolver.readthedocs.io/en/latest/.

Methods Summary

from_triples(mapped_triples, *, ...[, target])

Create LCWA instances from triples.

from_triples_factory(tf, **kwargs)

Create LCWA instances for triples factory.

Methods Documentation

classmethod from_triples(mapped_triples: Tensor, *, num_entities: int, num_relations: int, target: Literal[0, 1, 2] | Literal['head', 'relation', 'tail'] | None = None, **kwargs) Self[source]

Create LCWA instances from triples.

Parameters:
  • mapped_triples (Tensor) – shape: (num_triples, 3) The ID-based triples.

  • num_entities (int) – The number of entities.

  • num_relations (int) – The number of relations.

  • target (Literal[0, 1, 2] | ~typing.Literal['head', 'relation', 'tail'] | None) – The column to predict

  • kwargs – Additional keyword-based parameters passed to __init__()

Returns:

The instances.

Return type:

Self

classmethod from_triples_factory(tf: CoreTriplesFactory, **kwargs) Self[source]

Create LCWA instances for triples factory.

Parameters:
Returns:

The instances.

Return type:

Self