File size: 1,408 Bytes
c4a7c25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
import pandas as pd
from datasets import load_dataset

data = load_dataset('relbert/semeval2012_relational_similarity_v3')
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']),
                'level': i['level']
            })
df = pd.DataFrame(stats)
df_train = df[df['split'] == 'train']
df_valid = df[df['split'] == 'validation']
stats = []
for (relation_type, level), r in df.groupby(['relation_type', 'level']):
    _df_t = r[r['split'] == 'train']
    _df_v = r[r['split'] == 'validation']
    stats.append({
        'relation_type': relation_type,
        'level': level,
        '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())