init
Browse files- fewshot_link_prediction.py +1 -1
- stats.py +11 -10
fewshot_link_prediction.py
CHANGED
@@ -5,7 +5,7 @@ import datasets
|
|
5 |
logger = datasets.logging.get_logger(__name__)
|
6 |
_DESCRIPTION = """Few shots link prediction dataset. """
|
7 |
_NAME = "fewshot_link_prediction"
|
8 |
-
_VERSION = "0.0.
|
9 |
_CITATION = """
|
10 |
@inproceedings{xiong-etal-2018-one,
|
11 |
title = "One-Shot Relational Learning for Knowledge Graphs",
|
|
|
5 |
logger = datasets.logging.get_logger(__name__)
|
6 |
_DESCRIPTION = """Few shots link prediction dataset. """
|
7 |
_NAME = "fewshot_link_prediction"
|
8 |
+
_VERSION = "0.0.3"
|
9 |
_CITATION = """
|
10 |
@inproceedings{xiong-etal-2018-one,
|
11 |
title = "One-Shot Relational Learning for Knowledge Graphs",
|
stats.py
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
import pandas as pd
|
2 |
from datasets import load_dataset
|
3 |
|
4 |
-
|
5 |
-
|
|
|
6 |
|
7 |
-
print("\nEntity Types")
|
8 |
-
tail = df.groupby("tail_type")['relation'].count().to_dict()
|
9 |
-
head = df.groupby("head_type")['relation'].count().to_dict()
|
10 |
-
k = set(list(tail.keys()) + list(head.keys()))
|
11 |
-
df_types = pd.DataFrame([{"entity_type": _k, "tail": tail[_k] if _k in tail else 0, "head": head[_k] if _k in head else 0} for _k in k])
|
12 |
-
print(df_types.to_markdown(index=False))
|
13 |
|
14 |
-
print("\nRelation Types")
|
15 |
-
print(df.groupby("relation")['relation'].count().to_markdown())
|
16 |
|
17 |
|
|
|
1 |
import pandas as pd
|
2 |
from datasets import load_dataset
|
3 |
|
4 |
+
for _type in ['nell', 'nell_filter']:
|
5 |
+
data = load_dataset("fewshot_link_prediction", _type, split='test')
|
6 |
+
df = data.to_pandas()
|
7 |
|
8 |
+
print(f"\nEntity Types ({_type})")
|
9 |
+
tail = df.groupby("tail_type")['relation'].count().to_dict()
|
10 |
+
head = df.groupby("head_type")['relation'].count().to_dict()
|
11 |
+
k = set(list(tail.keys()) + list(head.keys()))
|
12 |
+
df_types = pd.DataFrame([{"entity_type": _k, "tail": tail[_k] if _k in tail else 0, "head": head[_k] if _k in head else 0} for _k in k])
|
13 |
+
print(df_types.to_markdown(index=False))
|
14 |
|
15 |
+
print(f"\nRelation Types ({_type})")
|
16 |
+
print(df.groupby("relation")['relation'].count().to_markdown())
|
17 |
|
18 |
|