亚马逊联合购买照片数据集
- class dgl.data.AmazonCoBuyPhotoDataset(raw_dir=None, force_reload=False, verbose=False, transform=None)[source]
基础类:
GNNBenchmarkDataset
用于节点分类任务的AmazonCoBuy数据集。
Amazon Computers 和 Amazon Photo 是 Amazon 共同购买图 [McAuley et al., 2015] 的一部分, 其中节点代表商品,边表示两种商品经常一起购买,节点特征是词袋编码的产品评论,类别标签由产品类别给出。
参考: https://github.com/shchur/gnn-benchmark#datasets
统计
节点数:7,650
边数:238,163(请注意,原始数据集有119,043条边,但DGL添加了反向边并去除了重复边,因此数量不同)
班级数量:8
节点特征大小:745
- 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 = AmazonCoBuyPhotoDataset() >>> 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:
图表包含:
ndata['feat']
: 节点特征ndata['label']
: 节点标签
- Return type:
- __len__()
数据集中的图表数量