Skip to content

WikiCS

WikiCS(
    is_undirected: bool = True,
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
)

Bases: Dataset

The semi-supervised Wikipedia-based dataset from the "Wiki-CS: A Wikipedia-Based Benchmark for Graph Neural Networks" paper.

Nodes represent Computer Science articles and edges hyperlinks between them. Node features are the averaged GloVe embeddings of the article text and the task is to predict which of the 10 branches of Computer Science each article belongs to.

The dataset comes with 20 train/validation/early-stopping splits stored as masks of shape [num_nodes, 20] in the train_mask, val_mask and stopping_mask attributes, and a single test split stored in test_mask (shape [num_nodes]).

This dataset follows the implementation of PyG.

Name #nodes #edges #features #classes
undirected (default) 11,701 431,726 300 10
directed 11,701 297,110 300 10

Parameters:

Name Type Description Default
is_undirected bool

Whether the graph is made undirected. Default: True (the default of PyG, where the original behavior was a directed graph).

True
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 WikiCS

dataset = WikiCS()
>>> wikics(num_graphs=1)

dataset[0]
>>> GraphData(
        edge_index(shape=(2, 431726), int32)
        node_features(shape=(11701, 300), float32)
        node_labels(shape=(11701,), int32)
        train_mask(shape=(11701, 20), bool)
        val_mask(shape=(11701, 20), bool)
        test_mask(shape=(11701,), bool)
        stopping_mask(shape=(11701, 20), bool))
Source code in mlx_graphs/datasets/wikics.py
def __init__(
    self,
    is_undirected: bool = True,
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
):
    self.is_undirected = is_undirected
    super().__init__(
        name="wikics",
        base_dir=base_dir,
        pre_transform=pre_transform,
        transform=transform,
    )

from mlx_graphs.datasets import WikiCS · mlx_graphs/datasets/wikics.py