Two metrics are available to estimate how hierarchical relations in a KG are: the curvature estimate and the Krackhardt hierarchy score. The curvature estimate captures global hierarchical behaviours (how much the graph is tree-like) and the Krackhardt score reflects more local behaviour (how many small loops the graph has). For details on computing metrics please refer to Low-Dimensional Hyperbolic Knowledge Graph Embeddings and Learning mixed-curvature representations in product spaces. To compute the metrics, use the graph_curvature.py script with the following arguments:
usage: graph_curvature.py [-h] [--dataset DATASET]
[--kg_type KG_TYPE]
[--curvature_type {'krackhardt', 'global_curvature'}]
[--relation RELATION]
Knowledge Graph Curvature
arguments:
-h, --help show this help message and exit
--dataset Knowledge Graph dataset
--kg_type Knowledge Graph type ('full' for full,'half' for sparse)
--curvature_type Curvature metric to compute ('krackhardt' for Krackhardt hierarchy score, 'global_curvature' for curvature estimate)
--relation Specific relation
If computing graph curvature is done before link prediction or separatly, plese make sure that the name of the dataset is according to the format <dataset>_<kg_type> and is placed inside the folder kge/data. To preprocess the dataset run the following command inside the folder data:
python preprocess/preprocess_default.py <dataset>_<kg_type>
Following is an example command to compute the Krackhardt hierarchy score for all relations in a KG:
python graph_curvature.py --dataset MetaQA --kg_type half --curvature_type krackhardt
or for a specific relation:
python graph_curvature.py --dataset MetaQA --kg_type half --curvature_type krackhardt --relation _instance_hypernym