Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
conceptnet / stats.py
asahi417's picture
fix readme
cf83452
raw
history blame contribute delete
852 Bytes
import pandas as pd
from datasets import load_dataset
def get_stats():
relation = []
size = []
data = load_dataset("relbert/conceptnet")
splits = data.keys()
for split in splits:
df = data[split].to_pandas()
size.append({
"number of pairs": len(df),
"number of unique relation types": len(df["relation"].unique())
})
relation.append(df.groupby('relation')['head'].count().to_dict())
relation = pd.DataFrame(relation, index=[f"number of pairs ({s})" for s in splits]).T
relation = relation.fillna(0).astype(int)
size = pd.DataFrame(size, index=splits).T
return relation, size
df_relation, df_size = get_stats()
print(f"\n- Number of instances\n\n {df_size.to_markdown()}")
print(f"\n- Number of pairs in each relation type\n\n {df_relation.to_markdown()}")