CoauthorCS数据集

class dgl.data.CoauthorCSDataset(raw_dir=None, force_reload=False, verbose=False, transform=None)[source]

Bases: GNNBenchmarkDataset

‘计算机科学 (CS)’ 是 Coauthor 数据集中用于节点分类任务的部分。

Coauthor CS 和 Coauthor Physics 是基于 KDD Cup 2016 挑战中的 Microsoft Academic Graph 的合著图。在这里,节点代表作者,如果两位作者合著了一篇论文,则通过边连接;节点特征代表每位作者论文的关键词,类别标签表示每位作者最活跃的研究领域。

Reference: https://github.com/shchur/gnn-benchmark#datasets

统计:

  • 节点数:18,333

  • 边数:163,788(请注意,原始数据集有81,894条边,但DGL添加了反向边并去除了重复项,因此数量不同)

  • 班级数量:15

  • 节点特征大小:6,805

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. The DGLGraph object will be transformed before every access.

num_classes

每个节点的类别数量。

Type:

int

示例

>>> data = CoauthorCSDataset()
>>> 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 features

  • ndata['label']: node labels

Return type:

dgl.DGLGraph

__len__()

数据集中的图表数量