File size: 1,229 Bytes
afcb4ea
 
 
e391af1
afcb4ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pandas as pd
from datasets import load_dataset

data = load_dataset('relbert/semeval2012_relational_similarity_v2')
stats = []
for k in data.keys():
    for i in data[k]:
        stats.append({'relation_type': i['relation_type'], 'split': k, 'positives': len(i['positives']), 'negatives': len(i['negatives'])})
df = pd.DataFrame(stats)
df_train = df[df['split'] == 'train']
df_valid = df[df['split'] == 'validation']
stats = []
for r in df['relation_type'].unique():
    _df_t = df_train[df_train['relation_type'] == r]
    _df_v = df_valid[df_valid['relation_type'] == r]
    stats.append({
        'relation_type': r,
        'positive (train)': 0 if len(_df_t) == 0 else _df_t['positives'].values[0],
        'negative (train)': 0 if len(_df_t) == 0 else _df_t['negatives'].values[0],
        'positive (validation)': 0 if len(_df_v) == 0 else _df_v['positives'].values[0],
        'negative (validation)': 0 if len(_df_v) == 0 else _df_v['negatives'].values[0],
    })

df = pd.DataFrame(stats).sort_values(by=['relation_type'])
df.index = df.pop('relation_type')
sum_pairs = df.sum(0)
df = df.T
df['SUM'] = sum_pairs
df = df.T

df.to_csv('stats.csv')
with open('stats.md', 'w') as f:
    f.write(df.to_markdown())