Graph Classification
What you'll learn: How to predict labels for entire graphs — essential for molecular property prediction, social network analysis, and protein function tasks.
Core Idea
While node classification assigns labels to individual nodes and link prediction finds missing edges, graph classification treats the entire graph as a single input and predicts a label or property for it. Think of it like image classification, but instead of classifying pixels arranged in a grid, you're classifying structured relationships.
For example:
- Molecular property prediction: Is this molecule toxic? What's its solubility?
- Protein function: What biological role does this protein structure serve?
- Social network analysis: Is this network a bot network or organic community?
How It Works
Graph classification requires two key steps:
1. Node-Level Feature Learning
First, you apply message passing layers (GCN, GraphSAGE, GAT, etc.) to learn rich representations for each node by aggregating neighborhood information. These layers capture local structure and node relationships.
2. Graph-Level Pooling (Readout)
After message passing, you have node embeddings but need a single vector representing the whole graph. Common readout functions include:
- Global mean/sum/max pooling: Aggregate all node features
- Hierarchical pooling: Coarsen the graph progressively (covered in lesson 2522)
- Attention-based readout: Weight nodes by importance
The resulting graph embedding feeds into a standard classifier (MLPs, softmax layers) for final prediction.
The Challenge
Unlike images with fixed sizes, graphs vary wildly in node count and structure. Your model must be permutation invariant — reordering nodes shouldn't change the prediction. Aggregation functions like sum and mean naturally satisfy this property.
Key Takeaway: Graph classification predicts properties of entire graphs by combining message passing for node features with global pooling to create graph-level embeddings, enabling applications from drug discovery to network security.