AmazonDataset
¶
AmazonDataset(
name: AMAZON_NAMES,
base_dir: Optional[str] = None,
pre_transform: Optional[Callable] = None,
transform: Optional[Callable] = None,
)
Bases: _NPZDataset
The Amazon Computers and Amazon Photo co-purchase graphs from the "Pitfalls of Graph Neural Network Evaluation" paper.
Nodes are products, edges connect products that are frequently bought together, node features are bag-of-words of the product reviews and the task is to predict the product category.
The datasets come without train/validation/test split; create one with
e.g. RandomNodeSplit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
AMAZON_NAMES
|
|
required |
base_dir
|
Optional[str]
|
Directory where to store dataset files. Default is
in the local directory |
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 AmazonDataset
dataset = AmazonDataset("computers")
>>> amazon_computers(num_graphs=1)
dataset[0]
>>> GraphData(
edge_index(shape=(2, 491722), int32)
node_features(shape=(13752, 767), float32)
node_labels(shape=(13752,), int32))
Source code in mlx_graphs/datasets/npz_dataset.py
from mlx_graphs.datasets import AmazonDataset · mlx_graphs/datasets/npz_dataset.py