Heating controller with neural thermal model written in Python
Jacek Kowalski
2018-06-24 66a9fb40efe1311b34a3cee3f83f10c6990759af
commit | author | age
425bf7 1 #!/usr/bin/env python3
JK 2
3 import collections
4 import csv
5 import glob
6 import statistics
7
8 # type-aggregation-model[-epochs]
9
10 results = {}
11
12 for filename in glob.glob('aggregation_*'):
13     with open(filename) as fp:
14         reader = csv.reader(fp, delimiter=' ')
15         for row in reader:
16             assert row[0] == 'RESULT'
17             
18             if row[1] not in results:
19                 results[row[1]] = [ [], [], [] ]
20             
21             for i in range(3):
22                 results[row[1]][i].append(float(row[2+i]))
23
24 def key_fix(x):
25     x = x[0].split('_')
26     
27     x[0] = {'past':0, 'flow': 1, 'fore':2, 'all':3}[x[0]]
28     x[1] = int(x[1])
29     if len(x) > 3:
30         x[3] = int(x[3])
31     return x
32
33 results = collections.OrderedDict(sorted(results.items(), key=key_fix))
34
35 last = None
36 for i in results:
37     it = i.split('_')
38     if it[0] != last:
39         print()
40         last = it[0]
41     print('-'.join(it[0:2]), '-'.join(it[2:]), end='')
42     for j in range(len(results[i])):
43         print('', statistics.mean(results[i][j]), statistics.stdev(results[i][j]), end='')
44     print()