Skip to content

Reddit

Reddit(
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
)

Bases: _LargeGraphDataset

The Reddit dataset from the "Inductive Representation Learning on Large Graphs" paper, containing Reddit posts belonging to different communities.

Nodes are posts, edges connect posts commented by the same user, node features are averaged GloVe embeddings of the post contents plus post statistics, and the task is to predict the community (subreddit) of each post. The split of the original paper is stored in train_mask / val_mask / test_mask.

This dataset follows the implementation of PyG (DGL's reddit.zip, coalesced edges). The download is 1.4 GB, the processed graph about 1.5 GB (edges stored as int32); processing needs about 6 GB of memory.

#nodes #edges #features #classes
232,965 114,615,892 602 41

Parameters:

Name Type Description Default
base_dir Optional[str]

Directory where to store dataset files. Default is in the local directory .mlx_graphs_data/.

None
pre_transform Optional[Callable]

A function/transform applied to the graph once, before it is saved.

None
transform Optional[Callable]

A function/transform applied to the graph at every access.

None

Example:

from mlx_graphs.datasets import Reddit

dataset = Reddit()
dataset[0]
>>> GraphData(
        edge_index(shape=(2, 114615892), int32)
        node_features(shape=(232965, 602), float32)
        node_labels(shape=(232965,), int32)
        train_mask(shape=(232965,), bool)
        val_mask(shape=(232965,), bool)
        test_mask(shape=(232965,), bool))
Source code in mlx_graphs/datasets/large_graph.py
def __init__(
    self,
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
):
    super().__init__(
        name="reddit",
        base_dir=base_dir,
        pre_transform=pre_transform,
        transform=transform,
    )

from mlx_graphs.datasets import Reddit · mlx_graphs/datasets/large_graph.py