Skip to content

OGBDataset

OGBDataset(
    name: ALL_DATASETS,
    split: Optional[Literal["train", "val", "test"]] = None,
    base_dir: Optional[str] = None,
)

Bases: Dataset

Datasets from the Open Graph Benchmark (OGB) collection of realistic, large-scale, and diverse benchmark datasets for machine learning on graphs.

Datasets belongs to three fundamental graph machine learning task categories: predicting the properties of nodes, links, and graphs. Node property prediction datasets consist of a single graph with three additional properties: train_mask, val_mask and test_mask specifying the masks for the train, validation and test splits. Link property prediction datasets also consist of a single graphs with three additional properties: train_edge_index, val_edge_index and test_edge_index, specifying the edges to be considered for training, validation and testing. Graph property prediction datasets consists of multiple graphs. The desired split can be specified via the split arg.

See here for further details and a list of the available datasets with their descriptions

Parameters:

Name Type Description Default
name ALL_DATASETS

Name of the dataset

required
split Optional[Literal['train', 'val', 'test']]

Split of the dataset to load. Thi parameter has effect only on graph property prediction dataset. If None, the entire dataset is loaded. Defaults to None.

None
base_dir Optional[str]

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

None

Note

ogb needs to be installed to use this dataset

Note

ogbn-mag is available as OGBMAG. The ogbl-wikikg2 and igbl-biokg and the graphs belonging to the largs-scale challenge category are currently not available as they require heterogenous graphs which are not yet supported by mlx-graphs

Example:

from mlx_graphs.datasets.ogb_dataset import OGBDataset

ds = OGBDataset("ogbg-molhiv", split="train")
>>> ogbg-molhiv(num_graphs=32901)
Source code in mlx_graphs/datasets/ogb_dataset.py
def __init__(
    self,
    name: ALL_DATASETS,
    split: Optional[Literal["train", "val", "test"]] = None,
    base_dir: Optional[str] = None,
):
    if name == "ogbn-mag":
        raise ValueError(
            "ogbn-mag is heterogeneous: use mlx_graphs.datasets.OGBMAG"
        )
    self.split = split
    self._raw_ogb_dataset = None
    super().__init__(name, base_dir)

from mlx_graphs.datasets import OGBDataset · mlx_graphs/datasets/ogb_dataset.py