From 7d06a51248574742a25c935f11ce95156afa06ca Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 26 Jan 2018 10:41:24 +0100 Subject: Only show SMAPE if it could be calculated --- lib/dfatool.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'lib/dfatool.py') 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'] + )) -- cgit v1.2.3