liveBook · Manning

Dataset split

As explained in Graph Algorithms for Data Science

A dataset split partitions available data into separate subsets for purposes such as feature generation, training, validation, and testing.

A dataset split separates available relationships or triples into training, testing, and validation subsets so a model can be evaluated on held-out data. section 10.2 section 11.2.2

Use the split differently depending on the features and prediction task:

  • For non-graph features such as age and education, allocate existing relationships between training and evaluation sets, such as 80% and 20%. section 10.2
  • Add negative examples so classification can distinguish existing relationships from unconnected node pairs; subsample negatives when their larger pool creates imbalance. section 10.2
  • Recompute graph-based features using the appropriate training relationships; otherwise network distance or embeddings can leak the target relationship into the features. section 10.2
  • For knowledge graph completion, specify training, testing, and validation ratios, with the validation ratio optionally inferred from the other two. section 11.2.2

Splitting triples with PyKEEN

Load source, relationship type, and target columns into a TriplesFactory, then call split([0.8, 0.1, 0.1], random_state=0) to create training, testing, and validation sets. section 11.2.2

Listing 11.3 Inputting triples to PyKEEN
from pykeen.triples import TriplesFactory

tf = TriplesFactory.from_labeled_triples(
   data[["source_name", "type", "target_name"]].values,
)

Inspect the PyKEEN setup that converts selected dataframe columns into labeled triples before splitting. section 11.2.2

Listing 11.4 Splitting the dataset into train, test, and validation sets
training, testing, validation = tf.split([0.8, 0.1, 0.1], random_state=0)

Inspect the executable PyKEEN call that assigns 80%, 10%, and 10% to training, testing, and validation. section 11.2.2

How Graph Algorithms for Data Science covers it

How deep it goes
Explains split ratios, negative-example balancing, leakage risks, and PyKEEN implementation, but not deeper sampling mechanics.
Examples
Uses person links with age and education, plus PyKEEN triples split into 0.8, 0.1, and 0.1 proportions.
What it assumes
Assumes labeled relationships or triples and distinguishes positive from negative examples; teaches leakage concerns when graph features are added.
What you can do after
Apply it via PyKEEN's TriplesFactory.split method and construct evaluation data for link prediction.
How it connects
Ties dataset split to link prediction, graph-based features, data leakage, negative examples, triples, and knowledge graph completion.

Also explained in

Compare how 21 books explain dataset split →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.