CoauthorPhysicsDataset
- class dgl.data.CoauthorPhysicsDataset(raw_dir=None, force_reload=False, verbose=False, transform=None)[source]
Bases:
GNNBenchmarkDataset
Coauthor 数据集中用于节点分类任务的“物理”部分。
Coauthor CS 和 Coauthor Physics 是基于 KDD Cup 2016 挑战中的 Microsoft Academic Graph 的合著图。在这里,节点代表作者,如果两位作者合著了一篇论文,则通过边连接;节点特征代表每位作者论文的关键词,类别标签表示每位作者最活跃的研究领域。
Reference: https://github.com/shchur/gnn-benchmark#datasets
统计
节点数:34,493
边数:495,924(请注意,原始数据集有247,962条边,但DGL添加了反向边并去除了重复边,因此数量不同)
类别数量:5
节点特征大小:8,415
- Parameters:
raw_dir (str) – Raw file directory to download/contains the input data directory. Default: ~/.dgl/
force_reload (bool) – Whether to reload the dataset. Default: False
verbose (bool) – Whether to print out progress information. Default: True.
transform (callable, optional) – A transform that takes in a
DGLGraph
object and returns a transformed version. TheDGLGraph
object will be transformed before every access.
示例
>>> data = CoauthorPhysicsDataset() >>> g = data[0] >>> num_class = data.num_classes >>> feat = g.ndata['feat'] # get node feature >>> label = g.ndata['label'] # get node labels
- __getitem__(idx)
通过索引获取图表
- Parameters:
idx (int) – Item index
- Returns:
The graph contains:
ndata['feat']
: node featuresndata['label']
: node labels
- Return type:
- __len__()
数据集中的图表数量