Skip to content

CoauthorDataset

CoauthorDataset(
    name: COAUTHOR_NAMES,
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
)

Bases: _NPZDataset

The Coauthor CS and Coauthor Physics co-authorship graphs from the "Pitfalls of Graph Neural Network Evaluation" paper, built from the Microsoft Academic Graph.

Nodes are authors, edges connect authors who co-authored a paper, node features are the keywords of each author's papers and the task is to predict each author's most active field of study.

The datasets come without train/validation/test split; create one with e.g. RandomNodeSplit.

Parameters:

Name Type Description Default
name COAUTHOR_NAMES

"cs" (18,333 nodes, 163,788 edges, 6,805 features, 15 classes) or "physics" (34,493 nodes, 495,924 edges, 8,415 features, 5 classes).

required
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 CoauthorDataset

dataset = CoauthorDataset("cs")
>>> coauthor_cs(num_graphs=1)

dataset[0]
>>> GraphData(
        edge_index(shape=(2, 163788), int32)
        node_features(shape=(18333, 6805), float32)
        node_labels(shape=(18333,), int32))
Source code in mlx_graphs/datasets/npz_dataset.py
def __init__(
    self,
    name: COAUTHOR_NAMES,
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
):
    assert name.lower() in get_args(COAUTHOR_NAMES), "Invalid dataset name"
    super().__init__(name, base_dir, pre_transform, transform)

from mlx_graphs.datasets import CoauthorDataset · mlx_graphs/datasets/npz_dataset.py