Splitter
- class Splitter[source]
Bases:
object
A method for splitting triples.
Methods Summary
split
(*, mapped_triples[, ratios, random_state])Split triples into clean groups.
split_absolute_size
(mapped_triples, sizes, ...)Split triples into clean groups.
Methods Documentation
- split(*, mapped_triples: Tensor, ratios: float | Sequence[float] = 0.8, random_state: None | int | Generator = None) Sequence[Tensor] [source]
Split triples into clean groups.
- Parameters:
mapped_triples (Tensor) – shape: (n, 3) the ID-based triples
random_state (None | int | Generator) – the random state used to shuffle and split the triples
ratios (float | Sequence[float]) – There are three options for this argument. First, a float can be given between 0 and 1.0, non-inclusive. The first set of triples will get this ratio and the second will get the rest. Second, a list of ratios can be given for which set in which order should get what ratios as in
[0.8, 0.1]
. The final ratio can be omitted because that can be calculated. Third, all ratios can be explicitly set in order such as in[0.8, 0.1, 0.1]
where the sum of all ratios is 1.0.
- Returns:
A partition of triples, which are split (approximately) according to the ratios.
- Return type:
- abstract split_absolute_size(mapped_triples: Tensor, sizes: Sequence[int], random_state: Generator) Sequence[Tensor] [source]
Split triples into clean groups.
This method partitions the triples, i.e., each triple is in exactly one group. Moreover, it ensures that the first group contains all entities at least once.
- Parameters:
- Returns:
a sequence of ID-based triples for each split part. the absolute may be different to ensure the constraint.
- Return type: