Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WikiLinks图神经网络链路预测 WikiLinks Graph Neural Network Link Prediction

bilibili

githubio GitHub Open In Colab

Python PyTorch License AUC training_progress_chinese_202601241601_final training_progress_english_202601241600_final

📊 Experimental Results & Visualization

The following figure shows the trend of loss decrease and AUC increase during model training:
Training progress animation
https://github.com/inneedloveBu/wikinet-link-prediction/animations/training_progress_english_20260124_160006.gif
Training progress gif

WikiNet: Hardness-Aware Link Prediction with Graph Neural Networks

bilibili githubio GitHub Open In Colab

Python PyTorch License AUC


Overview

WikiNet is a graph representation learning project designed to perform link prediction on a Wikipedia hyperlink network.

The task is formulated as a binary classification problem over node pairs.

The project focuses on:

  • Structural feature engineering
  • Hardness-aware negative sampling
  • Multi-interaction edge decoding
  • Robust training stabilization techniques

Dataset

The graph is constructed from the WikiLinks dataset.

Experimental Configuration

  • Number of nodes: 1000
  • Number of edges: 5000
  • Node feature dimension: 20 (structural + content features)

Data Split

  • Training edges: 1771
  • Validation edges: 253
  • Test edges: 507

Feature Engineering

Structural Features (via NetworkX)

  • Normalized degree
  • Clustering coefficient
  • Betweenness centrality
  • PageRank score
  • Neighbor statistics (mean / std / max / min degree)

Content-Based Features

  • Title length
  • Word count
  • Numeric token count
  • Uppercase ratio
  • Special character ratio
  • Hash-based embedding component

All features are standardized before training.


Model Architecture

Node Encoder

A 3-layer MLP encoder:

  • Linear → BatchNorm → ReLU → Dropout

  • Linear → BatchNorm → ReLU → Dropout

  • Linear projection layer

  • Hidden dimension: 64

  • Total trainable parameters: 21,729


Edge Interaction Mechanism

Instead of naive concatenation, the decoder integrates multiple interaction patterns:

  • Node embedding u
  • Node embedding v
  • Absolute difference |u − v|
  • Element-wise product u ⊙ v

These representations are concatenated and passed through an MLP classifier.

This design increases expressive power for link prediction tasks.


Hardness-Aware Negative Sampling

Three difficulty levels were implemented:

  • Easy — Random negative sampling
  • Medium — Common-neighbor-based sampling
  • Hard — Degree-similarity-based sampling

Final training uses:

  • Medium hardness sampling

This generates more informative negative edges and improves generalization.


Training Strategy

  • Binary Cross Entropy with logits

  • Class-weight balancing

  • Gradient clipping

  • Early stopping (patience = 20)

  • ReduceLROnPlateau learning rate scheduler

  • Best model checkpointing

  • Training epochs: 300

  • Best validation AUC: 0.897 (epoch 110)


Results

Test Set Performance

  • ROC-AUC: 0.798
  • Average Precision (AP): 0.784
  • F1-score: 0.763
  • Accuracy: 0.696

The model demonstrates stable generalization performance under controlled negative sampling.


Technical Stack

  • PyTorch 2.0+
  • PyTorch Geometric
  • NetworkX
  • NumPy
  • Pandas
  • scikit-learn
  • Matplotlib

Project Structure

wikinet-link-prediction/
├── data/
│   ├── raw/
│   └── cleaned/
├── models/
├── notebooks/
├── train11.py
├── requirements.txt
└── README.md

Quick Start

1. Clone Repository

git clone https://github.com/inneedloveBu/wikinet-link-prediction.git
cd wikinet-link-prediction

2. Install Dependencies

pip install -r requirements.txt

3. Run Training

python train11.py

Key Contributions

  • Designed hardness-controlled negative sampling mechanism
  • Implemented multi-interaction edge decoder
  • Combined structural and lightweight content features
  • Applied full training stabilization pipeline
  • Conducted systematic multi-metric evaluation

Future Improvements

  • Replace MLP encoder with GCN / GAT
  • Neighbor sampling for scalability
  • Larger-scale graph experiments
  • Embedding visualization
  • Interactive web deployment

License

  • MIT License

Contact


About

基于PyTorch Geometric的维基百科链接图链路预测Link prediction on the Wikipedia link graph based on PyTorch Geometric

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages