summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-10-22 16:14:08 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-10-22 16:14:08 +0200
commit2b28a0718f3712ac0dad5147ffe859a6c53f0c35 (patch)
tree962317bbe809ee14b8fe5607368bd5dbae5d6a30
parent3ae8c845103e2ad4f577c4bf195a1e81899cf518 (diff)
prepare proper overall error measures
-rwxr-xr-xbin/analyze-archive.py4
-rw-r--r--lib/dfatool.py11
2 files changed, 15 insertions, 0 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py
index fac8b00..99b3012 100755
--- a/bin/analyze-archive.py
+++ b/bin/analyze-archive.py
@@ -403,6 +403,10 @@ if __name__ == '__main__':
if 'table' in show_quality or 'all' in show_quality:
model_quality_table([static_quality, analytic_quality, lut_quality], [None, param_info, None])
+ if 'overall' in show_quality or 'all' in show_quality:
+ print('overall MAE of static model: {} µW'.format(model.assess_states(static_model)))
+ print('overall MAE of param model: {} µW'.format(model.assess_states(param_model)))
+ print('overall MAE of LUT model: {} µW'.format(model.assess_states(lut_model)))
if 'summary' in show_quality or 'all' in show_quality:
model_summary_table([model.assess_on_traces(static_model), model.assess_on_traces(param_model), model.assess_on_traces(lut_model)])
diff --git a/lib/dfatool.py b/lib/dfatool.py
index 4ba4911..dd9ed61 100644
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -1719,12 +1719,15 @@ class PTAModel:
return self.pta.to_json()
def states(self):
+ """Return sorted list of state names."""
return sorted(list(filter(lambda k: self.by_name[k]['isa'] == 'state', self.by_name.keys())))
def transitions(self):
+ """Return sorted list of transition names."""
return sorted(list(filter(lambda k: self.by_name[k]['isa'] == 'transition', self.by_name.keys())))
def states_and_transitions(self):
+ """Return list of states and transition names."""
ret = self.states()
ret.extend(self.transitions())
return ret
@@ -1760,6 +1763,14 @@ class PTAModel:
'by_name' : detailed_results
}
+ def assess_states(self, model_function, model_attribute = 'power'):
+ """
+ Calculate overall model error assuming equal distribution of states
+ """
+ model_quality = self.assess(model_function)
+ total_error = np.sqrt(sum(map(lambda x: np.square(model_quality['by_name'][x][model_attribute]['mae']), self.states())))
+ return total_error
+
def assess_on_traces(self, model_function):
"""