This project explores the power of Graph Convolutional Networks (GCNs) applied to a custom-built dataset of African nations.
Instead of treating countries as isolated data points (standard Machine Learning), we model the continent as a Graph where:
- Nodes are countries.
- Edges represent shared land borders.
- Node Features are economic/demographic indicators (GDP, Population).
The goal is to perform Semi-Supervised Node Classification to predict a country's geopolitical region based on its neighbors' influence, demonstrating how GNNs aggregate spatial information.
This implementation avoids high-level GNN libraries to focus on the mathematical mechanics of the Kipf & Welling (2017) propagation rule:
src/models.py: Custom PyTorch implementation of the Graph Convolution Layer.src/data.py: Manual construction of the African Adjacency Matrix and Feature set.src/utils.py: Spectral normalization of the adjacency matrix.
-
Install Dependencies
pip install -r requirements.txt
-
Execute the Training
python main.py
The model is trained on a subset of countries and tested on "hidden" nodes (e.g., Kenya, Togo) to verify generalization.
Input Features: GDP ($B), Population (M)
Graph: 15 Nodes, Undirected.
Test Accuracy: ~100% (Converges rapidly due to strong homophily in geopolitical borders).
The training script automatically generates a visualization of the graph, coloring nodes by their predicted region.
Created with passion for AI & Africa.
JeffreyYAJ