split
- split(mapped_triples: Tensor, *, ratios: float | Sequence[float] = 0.8, random_state: None | int | Generator = None, randomize_cleanup: bool = False, method: str | None = None) Sequence[Tensor] [source]
Split triples into clean groups.
- Parameters:
mapped_triples (Tensor) – shape: (n, 3) The ID-based 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.random_state (None | int | Generator) – The random state used to shuffle and split the triples.
randomize_cleanup (bool) – If true, uses the non-deterministic method for moving triples to the training set. This has the advantage that it does not necessarily have to move all of them, but it might be significantly slower since it moves one triple at a time.
method (str | None) – The name of the method to use, cf.
splitter_resolver
. Defaults to “coverage”, i.e.,CoverageSplitter
.
- Returns:
A partition of triples, which are split (approximately) according to the ratios.
- Return type:
ratio = 0.8 # makes a [0.8, 0.2] split train, test = split(triples, ratio) ratios = [0.8, 0.1] # makes a [0.8, 0.1, 0.1] split train, test, val = split(triples, ratios) ratios = [0.8, 0.1, 0.1] # also makes a [0.8, 0.1, 0.1] split train, test, val = split(triples, ratios)