Interview Prep

Interview: Representation & Data Preparation

Read learning notes.

Data Preparation

What is edge_index in PyTorch Geometric?

A tensor of shape $[2, \text{num\_edges}]$ in COO format. Row 0 = source nodes, row 1 = target nodes. For undirected graphs, include both $(i,j)$ and $(j,i)$.

How do you split data for link prediction without leakage?

Remove test edges from the training graph entirely before message passing. Train GNN on train edges only. Evaluate on held-out positive edges plus sampled negative non-edges. Never let the model see test edges during training.

What is the difference between inductive and transductive node splits?

Transductive: test nodes stay in the graph (structure visible, labels hidden). Inductive: test nodes/edges are removed from training graph - model must generalize to unseen structure.

When is building a k-NN graph from tabular data a bad idea?

When locality in feature space is not meaningful, when $k$ is arbitrary, or when relationships are not distance-based. Invented graphs can add noise and mislead GNNs. Try MLP baseline first.

What preprocessing steps are essential before GNN training?

Add/remove self-loops per model needs, make undirected edges bidirectional, handle isolated nodes, normalize features, create train/val/test masks, verify no label leakage across splits.

What are structural node features?

Features computed from graph structure: degree, clustering coefficient, PageRank, betweenness centrality, eigenvector centrality. Useful when raw attributes are weak but topology is informative.

Name key benchmark datasets and their tasks.

Cora/PubMed (node cls, citation), OGBN-Arxiv (large node cls), OGBN-Products (massive node cls), OGBG-MolHIV (graph cls, molecules), ZINC (graph regression). Use OGB splits for fair comparison.

What is a heterogeneous graph?

Multiple node types and edge types - e.g., users, products, brands with purchase and view relations. Requires type-specific message functions (R-GCN, HGT), not standard GCN.