WordNet18
¶
WordNet18(
base_dir: Optional[str] = None,
pre_transform: Optional[Callable] = None,
transform: Optional[Callable] = None,
)
Bases: _KnowledgeGraphDataset
The WordNet18 dataset from the "Translating Embeddings for Modeling Multi-Relational Data" paper, containing 40,943 entities, 18 relations and 151,442 fact triplets, e.g., furniture includes bed.
The three splits are merged in a single graph sorted by
(head, tail), with edge_type holding the relation of each triplet and
the train_mask, val_mask and test_mask edge masks telling the
split of each triplet.
This dataset follows the implementation of PyG.
Note
The original WordNet18 dataset suffers from test leakage, i.e.
more than 80% of test triplets can be found in the training set with
another relation type. Therefore, it should not be used for research
evaluation anymore. We recommend to use its cleaned version
WordNet18RR instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
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 WordNet18
dataset = WordNet18()
>>> WordNet18(num_graphs=1)
dataset[0]
>>> GraphData(
edge_index(shape=(2, 151442), int32)
edge_type(shape=(151442,), int32)
train_mask(shape=(151442,), bool)
val_mask(shape=(151442,), bool)
test_mask(shape=(151442,), bool)
num_nodes=40943)
Source code in mlx_graphs/datasets/knowledge_graph.py
from mlx_graphs.datasets import WordNet18 · mlx_graphs/datasets/knowledge_graph.py