-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate_table_rq2.py
39 lines (33 loc) · 1.44 KB
/
generate_table_rq2.py
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
import pandas as pd
import numpy as np
from itertools import product
datasets = ['gowalla']
models = ['SVDGCN']
metrics = ['recall']
samplings = []
alpha = 0.0
couples = list(product(models, datasets, metrics))
complete = {}
for metric in metrics:
for dataset in datasets:
path = f'./data/{dataset}/regression_{alpha}_{metric}_0_600.tsv'
complete.update({f'{metric}': pd.read_csv(path, sep='\t')})
table = []
for metric in metrics:
for model in models:
column = np.array([])
data = complete.get(f'{metric}')
data_model = data[data['model'] == model]
data_scores = [f"{item:.3f}" for item in data_model.iloc[:, 1:3].values.squeeze()]
data_chars = [f"{item:.3f}" for item in data_model.iloc[:, 3:15].values.squeeze()]
p_values = data_model.iloc[:, 15:].values.squeeze()
p_values = list(map(lambda p: '***' if p <= 0.001 else '**' if p <= 0.01 else '*' if p <= 0.05 else '',
p_values))
data_p_values = list(zip(data_chars, p_values))
data_p_values_formatted = [f'${v}^{{{p}}}$' for v, p in data_p_values]
data_scores_formatted = [f'${v1} ({v2})$' for v1, v2 in [tuple(data_scores)]]
column = np.r_[column, data_scores_formatted + data_p_values_formatted]
table.append(column.tolist())
report = pd.DataFrame(table).T
report.to_csv(f'./data/{datasets[0]}/table_{alpha}_rq2.tsv', sep="&", header=False, index=False)
print()