Metadata-Version: 2.4
Name: wikinet_link_prediction
Version: 1.0.0
Summary: WikiLinks Graph Neural Network for Link Prediction
Home-page: https://github.com/inneedloveBu/wikinet-link-prediction
Author: inneedloveBu
Author-email: indeedlove@foxmail.com
License: MIT
Project-URL: Bug Reports, https://github.com/inneedloveBu/wikinet-link-prediction/issues
Project-URL: Source, https://github.com/inneedloveBu/wikinet-link-prediction
Project-URL: Documentation, https://github.com/inneedloveBu/wikinet-link-prediction/wiki
Keywords: gnn,graph-neural-networks,link-prediction,machine-learning,pytorch
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=2.0.3
Requires-Dist: numpy>=1.24.3
Requires-Dist: scikit-learn>=1.3.0
Requires-Dist: matplotlib>=3.7.1
Requires-Dist: seaborn>=0.12.2
Requires-Dist: jupyter>=1.0.0
Requires-Dist: tqdm>=4.65.0
Requires-Dist: notebook>=6.5.4
Requires-Dist: ipython>=8.14.0
Requires-Dist: networkx>=3.1
Requires-Dist: streamlit>=1.24.0
Requires-Dist: requests>=2.31.0
Requires-Dist: beautifulsoup4>=4.12.2
Requires-Dist: torch>=2.0.0
Requires-Dist: torch-geometric>=2.4.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Provides-Extra: visualization
Requires-Dist: seaborn>=0.12.0; extra == "visualization"
Requires-Dist: plotly>=5.14.0; extra == "visualization"
Requires-Dist: networkx>=3.0; extra == "visualization"
Provides-Extra: gpu
Requires-Dist: torch>=2.0.0; extra == "gpu"
Requires-Dist: torch-geometric>=2.3.0; extra == "gpu"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# WikiLinks图神经网络链路预测
![Python](https://img.shields.io/badge/Python-3.8%2B-blue)
![PyTorch](https://img.shields.io/badge/PyTorch-2.0%2B-red)
![License](https://img.shields.io/badge/License-MIT-green)
![AUC](https://img.shields.io/badge/AUC-0.7976-orange)


一个基于PyTorch Geometric的图神经网络项目，用于维基百科链接图的链路预测任务。

## 📊 项目概述

本项目实现了对维基百科链接图的链路预测，使用改进的图神经网络模型和特征工程方法，取得了显著的效果提升。

### 主要成果
- **测试集AUC**: 0.7976
- **测试集AP**: 0.7841  
- **测试集F1分数**: 0.7627
- **准确率**: 0.6964

## 🏗️ 项目结构
wikinet/
├── data/ # 数据目录
│ ├── raw/ # 原始数据（需自行下载）
│ └── cleaned/ # 清洗后的数据
├── models/ # 模型文件
├── train11.py # 主训练脚本
├── requirements.txt # 依赖包列表
├── README.md # 项目说明
└── .gitignore # Git忽略文件

text

## 🚀 快速开始

### 1. 环境安装
```bash
# 克隆项目
git clone https://github.com/inneedloveBu/wikinet-link-prediction.git
cd wikinet-link-prediction

# 创建虚拟环境（可选）
python -m venv venv
source venv/bin/activate  # Linux/Mac
# 或
venv\Scripts\activate     # Windows

# 安装依赖
pip install -r requirements.txt
2. 数据准备
下载WikiLinks数据集：

访问：https://zenodo.org/record/1193740

下载 enwiki.wikilink_graph.2018-03-01.csv.gz

将文件放置在 data/raw/ 目录下

3. 运行训练
bash
python train11.py
🔬 技术特点
数据预处理
连通分量提取：自动提取最大连通分量

数据增强：智能添加随机边以解决稀疏问题

特征工程：结合结构特征和内容特征

模型架构
简化但有效的模型设计：21,729个参数

多种特征交互方式：拼接、差值、乘积

正则化策略：Dropout + BatchNorm

训练策略
困难负采样：按不同难度级别生成负样本

早停机制：自动保存最佳模型

学习率调度：动态调整学习率

📈 实验结果
训练曲线
https://models/improved_experiment_results.png

关键指标
指标	数值	说明
测试集AUC	0.7976	分类器性能优秀
测试集AP	0.7841	精度-召回平衡良好
F1分数	0.7627	综合性能指标
准确率	0.6964	基础分类准确度
图结构分析
节点数: 114

边数: 700

边密度: 10.87%

平均度: 12.28

聚类系数: 0.4368

📂 文件说明
主要脚本
train11.py：主训练脚本，包含数据加载、特征提取、模型训练和评估

输出文件
data/cleaned/：清洗后的数据文件

cleaned_edges.txt：清洗后的边数据

cleaned_nodes.txt：清洗后的节点数据

graph_stats.json：图统计信息

models/：模型和结果文件

best_improved_model.pt：最佳模型权重

improved_training_history.json：训练历史

improved_experiment_results.png：可视化图表

🛠️ 自定义配置
你可以通过修改以下参数来调整实验：

python
# 在train11.py的main()函数中修改
target_nodes = 150      # 目标节点数
target_edges = 700      # 目标边数
num_epochs = 300        # 训练轮数
hidden_dim = 64         # 隐藏层维度
learning_rate = 0.01    # 学习率
🤝 贡献指南
欢迎贡献！请遵循以下步骤：

Fork 本仓库

创建功能分支 (git checkout -b feature/AmazingFeature)

提交更改 (git commit -m 'Add some AmazingFeature')

推送到分支 (git push origin feature/AmazingFeature)

开启 Pull Request

📄 许可证
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情

🙏 致谢
数据来源：维基百科WikiLinks数据集

框架：PyTorch Geometric, NetworkX, scikit-learn

## 📚 参考文献与致谢

本项目在实现过程中参考或基于以下优秀的研究工作，在此向原作者致谢：

1.  **图卷积网络 (GCN) 的奠基工作**：
    ```bibtex
    @article{kipf2016semi,
      title={Semi-Supervised Classification with Graph Convolutional Networks},
      author={Kipf, Thomas N. and Welling, Max},
      journal={arXiv preprint arXiv:1609.02907},
      year={2016}
    }
    ```
2.  **大规模图表示学习**：
    ```bibtex
    @inproceedings{hamilton2017inductive,
      title={Inductive Representation Learning on Large Graphs},
      author={Hamilton, Will and Ying, Rex and Leskovec, Jure},
      booktitle={Advances in Neural Information Processing Systems},
      pages={1024--1034},
      year={2017}
    }
    ```
3.  **链路预测的经典方法**（可选，如果你的模型有比较对象）：
    - Liben-Nowell, D., & Kleinberg, J. (2007). The link-prediction problem for social networks. *Journal of the American Society for Information Science and Technology*.

**如果本项目的代码或思路对您的研究有帮助，请考虑引用上述相关文献。**


📞 联系方式
如有问题或建议，请通过以下方式联系：

项目issue：https://github.com/inneedoveBu/wikinet-link-prediction/issues

邮件：indeedlove@foxmail.com

⭐ 如果这个项目对你有帮助，请给个Star！
