AmazonCoBuyPhotoDataset(raw_dir=None, force_reload=False, verbose=False, transform=None)[source]¶
AmazonCoBuy dataset for node classification task.
Deprecated since version 0.5.0:
datais deprecated, it is repalced by:
>>> dataset = AmazonCoBuyPhotoDataset() >>> graph = dataset
Amazon Computers and Amazon Photo are segments of the Amazon co-purchase graph [McAuley et al., 2015], where nodes represent goods, edges indicate that two goods are frequently bought together, node features are bag-of-words encoded product reviews, and class labels are given by the product category.
Edges: 238,163 (note that the original dataset has 119,043 edges but DGL adds the reverse edges and remove the duplicates, hence with a different number)
Number of classes: 8
Node feature size: 745
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
DGLGraphobject and returns a transformed version. The
DGLGraphobject will be transformed before every access.
>>> data = AmazonCoBuyPhotoDataset() >>> g = data >>> num_class = data.num_classes >>> feat = g.ndata['feat'] # get node feature >>> label = g.ndata['label'] # get node labels
Get graph by index
idx (int) – Item index
The graph contains:
ndata['feat']: node features
ndata['label']: node labels
- Return type
Number of graphs in the dataset