Skip to content

HeteroDataset

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

Bases: BaseDataset

A dataset class for handling heterogeneous graph data.

Parameters:

Name Type Description Default
name str

name of the dataset

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 that takes in a HeteroGraphData object and returns a transformed version. The transformation is applied before the first access.

None
transform Optional[Callable]

A function/transform that takes in a HeteroGraphData object and returns a transformed version. The transformation is applied before every access, i.e., during the __getitem__ call. By default, no transformation is applied.

None

Attributes:

Name Type Description
num_node_features dict[str, int]

Returns a dictionary of the number of node features for each node type.

num_edge_features dict[str, int]

Returns a dictionary of the number of edge features for each edge type.

num_graph_features int

Returns the number of graph features.

num_node_classes Union[dict[str, int], None]

Returns a dictionary of the number of node classes for each node type.

num_edge_classes dict[Any, int]

Returns a dictionary of the number of edge classes for each edge type.

num_nodes dict[str, int]

Returns a dictionary of the number of nodes for each node type.

num_edges dict[Any, int]

Returns a dictionary of the number of edges for each edge type.

Source code in mlx_graphs/datasets/hetero_dataset.py
def __init__(
    self,
    name: str,
    base_dir: Optional[str] = None,
    pre_transform: Optional[Callable] = None,
    transform: Optional[Callable] = None,
):
    self._name = name
    self._base_dir = base_dir if base_dir else DEFAULT_BASE_DIR
    self.transform = transform
    self.pre_transform = pre_transform
    self.graphs: list[HeteroGraphData] = []
    self._load()

num_node_features property

num_node_features: dict[str, int]

Returns a dictionary of the number of node features for each node type.

num_edge_features property

num_edge_features: dict[str, int]

Returns a dictionary of the number of edge features for each edge type.

num_graph_features property

num_graph_features: int

Returns the number of graph features.

num_node_classes property

num_node_classes: Union[dict[str, int], None]

Returns a dictionary of the number of node classes for each node type.

num_edge_classes property

num_edge_classes: dict[Any, int]

Returns a dictionary of the number of edge classes for each edge type.

num_nodes property

num_nodes: dict[str, int]

Returns a dictionary of the number of nodes for each node type.

num_edges property

num_edges: dict[Any, int]

Returns a dictionary of the number of edges for each edge type.

from mlx_graphs.datasets import HeteroDataset · mlx_graphs/datasets/hetero_dataset.py