summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-01-26 10:41:24 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-01-26 10:41:24 +0100
commit7d06a51248574742a25c935f11ce95156afa06ca (patch)
tree17d53f677fe3910a7f59b4f0ec6914ebddc33988 /lib
parent56011e9f63fffacd734c843e2106017f2a24e727 (diff)
Only show SMAPE if it could be calculated
Diffstat (limited to 'lib')
-rwxr-xr-xlib/dfatool.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py
index 5cece86..41d5d37 100755
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -371,16 +371,26 @@ class EnergyModel:
if elem['isa'] == 'state':
predicted_data = np.array(list(map(lambda x: model_function(name, 'power'), elem['power'])))
measures = regression_measures(predicted_data, elem['power'])
- print(' power: {:.2f}% / {:.0f} µW'.format(
- measures['smape'], measures['mae']
- ))
+ if 'smape' in measures:
+ print(' power: {:.2f}% / {:.0f} µW'.format(
+ measures['smape'], measures['mae']
+ ))
+ else:
+ print(' power: {:.0f} µW'.format(
+ measures['mae']
+ ))
else:
for key in ['duration', 'energy', 'rel_energy_prev', 'rel_energy_next']:
predicted_data = np.array(list(map(lambda x: model_function(name, key), elem[key])))
measures = regression_measures(predicted_data, elem[key])
- print(' {:10s}: {:.2f}% / {:.0f}'.format(
- key, measures['smape'], measures['mae']
- ))
+ if 'smape' in measures:
+ print(' {:10s}: {:.2f}% / {:.0f}'.format(
+ key, measures['smape'], measures['mae']
+ ))
+ else:
+ print(' {:10s}: {:.0f}'.format(
+ key, measures['mae']
+ ))