-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_cifar_classifier_experiment_results.py
38 lines (32 loc) · 1.59 KB
/
process_cifar_classifier_experiment_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
import numpy as np
import pickle
import sys
def fp(num):
return np.format_float_positional(num, trim='-')
output_filename = sys.argv[1]
input_filenames = sys.argv[2:]
results = []
for filename in input_filenames:
with open(filename, "rb") as f:
results.append(pickle.load(f))
by_max_accuracy = sorted(results, key=lambda x: -x['statistics']['max_accuracy'])
table_lines = list(
map(
lambda x: "{max_accuracy:.3f} & {ageism_factor} & {min_n_genes} & {max_n_genes} & {elitism_fraction} & {mutation_probability} & {mean_threshold} & {std_threshold} \\\\ ".format(max_accuracy=x['statistics']['max_accuracy'], ageism_factor=x['hyperparameters']['ageism_factor'], min_n_genes=x['hyperparameters']['min_n_genes'], max_n_genes=x['hyperparameters']['max_n_genes'], elitism_fraction=fp(x['hyperparameters']['elitism_fraction']), mutation_probability=fp(x['hyperparameters']['mutation_probability']), mean_threshold=fp(x['hyperparameters']['mean_threshold']), std_threshold=fp(x['hyperparameters']['std_threshold'])),
by_max_accuracy
)
)
table_lines = " \hline\n".join(table_lines)
# {max_accuracy:.3f} & {min_n_genes} & {max_n_genes} & {elitism_fraction} & {mutation_probability} & {mean_threshold} & {std_threshold}
table_code = f"""
\\begin{{tabularx}}{{\\textwidth}}{{ | X || X | X | X | X | X | X | X | }}
\\hline
Max accuracy & Ageism factor & Min \\# genes & Max \# genes & Elitism fraction & Mutation prob & Mean threshold & Standard deviation threshold \\\\
\\hline
\\hline
{table_lines}
\\hline
\\end{{tabularx}}
"""
with open(output_filename, "w") as f:
f.write(table_code)