-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_mis_3_results.py
131 lines (112 loc) · 5.62 KB
/
process_mis_3_results.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import json
from collections import defaultdict
import numpy as np
# Read the JSON file
with open('results_mis_3_prod_multidimensional_aux.txt') as f:
data = json.load(f)
variances, errors, std_devs = defaultdict(lambda: defaultdict(list)), defaultdict(lambda: defaultdict(list)), defaultdict(lambda: defaultdict(list))
# Iterating through the JSON data to extract the necessary statistics
for test in data.values():
for heuristic, sample_data in test.items():
for sample_size, stats in sample_data.items():
variances[heuristic][sample_size].append(stats['mean of variance'])
errors[heuristic][sample_size].append(stats['mean of error'])
std_devs[heuristic][sample_size].append(stats['mean of standard deviation'])
# Calculating the means for each heuristic and sample size
mean_variances = {heuristic: {size: np.mean(values) for size, values in sizes.items()} for heuristic, sizes in variances.items()}
mean_errors = {heuristic: {size: np.mean(values) for size, values in sizes.items()} for heuristic, sizes in errors.items()}
mean_std_devs = {heuristic: {size: np.mean(values) for size, values in sizes.items()} for heuristic, sizes in std_devs.items()}
# Printing the means
print("Analysis of the results per heuristic and sample size:")
print('Mean of variances:')
print(mean_variances)
print('Mean of errors:')
print(mean_errors)
print('Mean of standard deviations:')
print(mean_std_devs)
print("*" * 10)
# Iterate through tests
print("Analysis of the results per heuristic in each test:")
for i, test in enumerate(data.values()):
variances, errors, std_devs = defaultdict(list), defaultdict(list), defaultdict(list)
for heuristic, sample_data in test.items():
for sample_size, stats in sample_data.items():
variances[heuristic].append(stats['mean of variance'])
errors[heuristic].append(stats['mean of error'])
std_devs[heuristic].append(stats['mean of standard deviation'])
# Calculating the means for each heuristic and sample size
mean_variances = {heuristic: np.mean(values) for heuristic, values in variances.items()}
mean_errors = {heuristic: np.mean(values) for heuristic, values in errors.items()}
mean_std_devs = {heuristic: np.mean(values) for heuristic, values in std_devs.items()}
print('Test: ', i + 1)
print('Mean of variances:')
print(mean_variances)
print('Mean of errors:')
print(mean_errors)
print('Mean of standard deviations:')
print(mean_std_devs)
print("*" * 10)
# Iterating through heuristics
print("Analysis of the results per heuristic:")
balance_variances, balance_errors, balance_std_devs = [], [], []
power_variances, power_errors, power_std_devs = [], [], []
maximum_variances, maximum_errors, maximum_std_devs = [], [], []
cutoff_variances, cutoff_errors, cutoff_std_devs = [], [], []
sbert_variances, sbert_errors, sbert_std_devs = [], [], []
for test in data.values():
for heuristic, sample_data in test.items():
for sample_size, stats in sample_data.items():
if heuristic == 'balance':
balance_variances.append(stats['mean of variance'])
balance_errors.append(stats['mean of error'])
balance_std_devs.append(stats['mean of standard deviation'])
elif heuristic == 'power':
power_variances.append(stats['mean of variance'])
power_errors.append(stats['mean of error'])
power_std_devs.append(stats['mean of standard deviation'])
elif heuristic == 'maximum':
maximum_variances.append(stats['mean of variance'])
maximum_errors.append(stats['mean of error'])
maximum_std_devs.append(stats['mean of standard deviation'])
elif heuristic == 'cutoff':
cutoff_variances.append(stats['mean of variance'])
cutoff_errors.append(stats['mean of error'])
cutoff_std_devs.append(stats['mean of standard deviation'])
elif heuristic == 'sbert':
sbert_variances.append(stats['mean of variance'])
sbert_errors.append(stats['mean of error'])
sbert_std_devs.append(stats['mean of standard deviation'])
# Calculating the means for each heuristic and sample size
mean_balance_variances = np.mean(balance_variances)
mean_balance_errors = np.mean(balance_errors)
mean_balance_std_devs = np.mean(balance_std_devs)
mean_power_variances = np.mean(power_variances)
mean_power_errors = np.mean(power_errors)
mean_power_std_devs = np.mean(power_std_devs)
mean_maximum_variances = np.mean(maximum_variances)
mean_maximum_errors = np.mean(maximum_errors)
mean_maximum_std_devs = np.mean(maximum_std_devs)
mean_cutoff_variances = np.mean(cutoff_variances)
mean_cutoff_errors = np.mean(cutoff_errors)
mean_cutoff_std_devs = np.mean(cutoff_std_devs)
mean_sbert_variances = np.mean(sbert_variances)
mean_sbert_errors = np.mean(sbert_errors)
mean_sbert_std_devs = np.mean(sbert_std_devs)
print('Mean of variances:')
print('balance: ', mean_balance_variances)
print('power: ', mean_power_variances)
print('maximum: ', mean_maximum_variances)
print('cutoff: ', mean_cutoff_variances)
print('sbert: ', mean_sbert_variances)
print('Mean of errors:')
print('balance: ', mean_balance_errors)
print('power: ', mean_power_errors)
print('maximum: ', mean_maximum_errors)
print('cutoff: ', mean_cutoff_errors)
print('sbert: ', mean_sbert_errors)
print('Mean of standard deviations:')
print('balance: ', mean_balance_std_devs)
print('power: ', mean_power_std_devs)
print('maximum: ', mean_maximum_std_devs)
print('cutoff: ', mean_cutoff_std_devs)
print('sbert: ', mean_sbert_std_devs)