Data Layout — Rigorous Reference
3.1 Top-Level Directory Structure
Design principle: The pipeline auto-discovers all node and edge types from directory contents. You do not hardcode entity or relationship names anywhere; the file names are the names.
All edge types are message-passing channels. Every edge file in
edges/is loaded into the GNN graph, not just the labeled (predicted) edge type. Context edges (e.g.customer_holds_account.csv,device_initiates_account.csv) enrich the neighbourhood signal for the predicted edge type. Adding or removing a context edge file changes the model’s receptive field, its feature dimension, and the expected Triton input schema — the model must be retrained whenever the edge set changes.
3.2 Node Files
Location: nodes/{node_type}.csv
The file stem (name without extension) is used as the node type identifier throughout the entire pipeline — in the GNN graph schema, the Triton config, and the inference client. You can use any names that fit your domain; short, lowercase, singular names are recommended for readability.
Format requirements:
Example — nodes/account.csv:
Row 0 (account ID 0): balance 327.35, 3 overdrafts, active, account type 3 (binary 11).
Row 1 (account ID 1): balance 1792.95, account type 2 (binary 01).
Example — nodes/merchant.csv:
3.3 Edge Files
All edge files share a common naming stem derived from a three-part type triple:
How the Parser Works
The pipeline splits the filename stem on every _ and assigns:
Minimum requirement: at least three _-separated tokens — one for src, at least one for rel, one for dst.
Valid examples:
Invalid examples — these will fail validation:
src and dst are always the first and last token respectively. If your node file is nodes/credit_card.csv (stem = credit_card), you cannot use it as src because the parser will take only credit as src and card will be absorbed into rel. Either rename the node file to nodes/creditcard.csv and use creditcard as the first token, or accept that credit becomes the logical node type name.3.3.1 Connectivity File (required for every edge type)
File: edges/{src}_{rel}_{dst}.csv
Two columns read positionally (first = source node ID, second = destination node ID). The column headers can be any names — the pipeline reads the first two columns regardless of name. The conventional names src and dst are recommended for clarity and are required by the validation commands in Section 3.6.
Row 0: node 495 in account.csv is connected through one transaction to node 87 in merchant.csv.
rev_{rel}) for bidirectional message passing during GNN training. You do not need to add them yourself.3.3.2 Label File
Edge Prediction (EP) — File: edges/{src}_{rel}_{dst}_label.csv
A single column containing the fraud label for each edge. The column header can be any name; only the last column is read (iloc[:, -1]). For single-column files this makes no difference, but avoid appending extra columns after the label column (e.g. an ID column), as the last column would then be read as the label. Must have exactly the same number of rows as the connectivity file.
1 = fraudulent. 0 = legitimate.
The pipeline automatically detects which edge type has a label file and uses it as the prediction target. Exactly one edge type should have a label file. If zero or multiple label files are found, training will fail with a clear error.
Node Prediction (NP) — File: nodes/{node_type}_label.csv
For node-level fraud prediction (kind: GNN_XGBoost_NP), place the label file in the nodes/ directory alongside the node feature file:
Same single-column format as the EP label file. The stem must exactly match the target node type filename (e.g. account_label.csv targets nodes in account.csv). The pipeline detects this automatically.
3.3.3 Edge Attribute File (optional but recommended)
File: edges/{src}_{rel}_{dst}_attr.csv
Per-transaction features that do not naturally belong to either endpoint node. Classic examples: transaction amount, time of day, day of week, payment channel (ATM / in-store / online), whether a chip was used.
These attributes are concatenated with the GNN-derived node embeddings to form the final edge embedding passed into XGBoost. They are also exposed to the LLM explainer if a feature_map.json is present.
(train-val-test-mask-files-optional)=
3.3.4 Train/Val/Test Mask Files (optional)
By default the pipeline applies a fixed 90/10 stratified train/val split (hardcoded, no config parameters control the ratio). To use a custom, reproducible split instead, provide boolean NumPy mask arrays:
Edge Prediction (EP): place masks alongside the edge files:
Node Prediction (NP): place masks alongside the node files:
Each mask is a bool NumPy array saved with np.save. True means the corresponding edge or node belongs to that split. The three masks are mutually exclusive and together cover the full labeled set. If no mask files are present the pipeline falls back to the default 90/10 split. If any mask files are detected, train_mask.npy and val_mask.npy must both be provided (the pipeline raises an error if either is missing); test_mask.npy is optional.
Masks are always
.npy— this is not configurable. The mask format is intentionally decoupled from the node/edge file format (CSV, Parquet, or ORC). NumPy binary arrays are compact, platform-portable, and avoid the row-count ambiguity of text formats. There is no benefit to storing a boolean vector in Parquet or ORC, and the overhead of a Parquet reader for a single 1-D boolean array would be unnecessary.
3.4 The Test Split
The test_gnn/ subdirectory is a completely separate graph used only for final evaluation — the pipeline never sees its labels during training or threshold calibration.
Important considerations:
- Temporal correctness: If your data has a time dimension, the test split should contain transactions from a later time period than training. Splitting randomly can leak future information and produce unrealistically optimistic metrics.
- Node overlap is acceptable. The same account or merchant can appear in both the training and test graphs. The test set evaluates the model’s generalisation on new transactions, not new entities.
- Minimum size: At least a few thousand edges, with a reasonable number of fraud cases (≥ 100 fraud edges recommended for stable metric estimates).
3.5 Supported File Formats
The pipeline auto-detects format by file extension. Node, edge, label, and attribute files can use any of the following:
Mixing formats is fully supported. You can have nodes/user.parquet alongside edges/user_to_merchant.orc — each file is read independently based on its own extension. The label file (e.g. user_to_merchant_label.csv) must use an extension the pipeline recognises, but it does not need to match the extension of the edge file.
Mask files are always
.npyregardless of data format. See Section 3.3.4.
Parquet/ORC written on a different machine: if you generate Parquet files on the host and train inside the container, ensure the pyarrow versions are compatible. When in doubt, convert inside the container:
3.6 Pre-Training Data Validation Checklist
Run these checks before starting training to avoid hard-to-diagnose errors mid-run.
Substitute your own names throughout: Replace
account_transacts_merchantwith your labeled edge stem,accountwith your source node type, andmerchantwith your destination node type in every command below.