-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhyperparameter_test_standard_deviation.py
More file actions
46 lines (34 loc) · 1.38 KB
/
hyperparameter_test_standard_deviation.py
File metadata and controls
46 lines (34 loc) · 1.38 KB
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
# script to calculate the standard deviation of EDDP hyperparameter test MAE and RMSE values
# works with the hyperparameter_test.dat output from hyperparameter_test.sh
# written by Pascal Salzbrenner, pts28@cam.ac.uk
import numpy as np
# open input and output files
infile = open("hyperparameter_test.dat", "r")
outfile = open("hyperparameter_test_standard_deviation.dat", "w")
# set up dictionary to contain the data
data_dict = {}
# read in the data
header = infile.readline()
outfile.write(header)
for line in infile:
data = line.split()
radial_cutoff = data[0]
polynomials = data[1]
rmse = float(data[3])
mae = float(data[4])
# add to the dictionary
if radial_cutoff not in data_dict:
data_dict[radial_cutoff] = {}
if polynomials not in data_dict[radial_cutoff]:
data_dict[radial_cutoff][polynomials] = [[], []]
data_dict[radial_cutoff][polynomials][0].append(rmse)
data_dict[radial_cutoff][polynomials][1].append(mae)
# calculate the standard deviation and write to the output file
for radial_cutoff in data_dict:
for polynomials in data_dict[radial_cutoff]:
rmse_std = np.std(data_dict[radial_cutoff][polynomials][0])
mae_std = np.std(data_dict[radial_cutoff][polynomials][1])
outfile.write("%s %s %f %f\n" % (radial_cutoff, polynomials, rmse_std, mae_std))
# close the files
infile.close()
outfile.close()