YelpDataset

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

Bases: dgl.data.dgl_dataset.DGLBuiltinDataset

Yelp dataset for node classification from GraphSAINT: Graph Sampling Based Inductive Learning Method

The task of this dataset is categorizing types of businesses based on customer reviewers and friendship.

Yelp dataset statistics:

  • Nodes: 716,847

  • Edges: 13,954,819

  • Number of classes: 100 (Multi-class)

  • Node feature size: 300

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: False

  • 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.

  • reorder (bool) – Whether to reorder the graph using reorder_graph(). Default: False.

num_classes

Number of node classes

Type

int

Examples

>>> dataset = YelpDataset()
>>> dataset.num_classes
100
>>> g = dataset[0]
>>> # get node feature
>>> feat = g.ndata['feat']
>>> # get node labels
>>> labels = g.ndata['label']
>>> # get data split
>>> train_mask = g.ndata['train_mask']
>>> val_mask = g.ndata['val_mask']
>>> test_mask = g.ndata['test_mask']
__getitem__(idx)[source]

Get graph object

Parameters

idx (int) – Item index, FlickrDataset has only one graph object

Returns

The graph contains:

  • ndata['label']: node label

  • ndata['feat']: node feature

  • ndata['train_mask']: mask for training node set

  • ndata['val_mask']: mask for validation node set

  • ndata['test_mask']: mask for test node set

Return type

dgl.DGLGraph

__len__()[source]

The number of graphs in the dataset.