summaryrefslogtreecommitdiff
path: root/lib/model.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-03-08 14:20:42 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-03-08 14:20:42 +0100
commit4f763f85e9f572b56e3465ccd47641c71cdb8bbf (patch)
treeafe598fa0c21876047ef4d3517d1835084b48763 /lib/model.py
parent3865ca8f08181fa18d14aa924a0a1388cd5f54ee (diff)
add dataref export
Diffstat (limited to 'lib/model.py')
-rw-r--r--lib/model.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/model.py b/lib/model.py
index 527a19e..85cda71 100644
--- a/lib/model.py
+++ b/lib/model.py
@@ -311,6 +311,48 @@ class AnalyticModel:
return {"by_name": detailed_results}
+ def to_dref(self, static_quality, lut_quality, model_quality) -> dict:
+ ret = dict()
+ for name in self.names:
+ for attr_name, attr in self.attr_by_name[name].items():
+ e_static = static_quality["by_name"][name][attr_name]
+ e_lut = lut_quality["by_name"][name][attr_name]
+ e_model = model_quality["by_name"][name][attr_name]
+ unit = None
+ if "power" in attr.attr:
+ unit = r"\micro\watt"
+ elif "energy" in attr.attr:
+ unit = r"\pico\joule"
+ elif attr.attr == "duration":
+ unit = r"\micro\second"
+ for k, v in attr.to_dref(unit).items():
+ ret[f"data/{name}/{attr_name}/{k}"] = v
+ ret[f"error/static/{name}/{attr_name}/mae"] = (e_static["mae"], unit)
+ ret[f"error/lut/{name}/{attr_name}/mae"] = (e_lut["mae"], unit)
+ ret[f"error/model/{name}/{attr_name}/mae"] = (e_model["mae"], unit)
+ ret[f"error/static/{name}/{attr_name}/smape"] = (
+ e_static["smape"],
+ r"\percent",
+ )
+ ret[f"error/lut/{name}/{attr_name}/smape"] = (
+ e_lut["smape"],
+ r"\percent",
+ )
+ ret[f"error/model/{name}/{attr_name}/smape"] = (
+ e_model["smape"],
+ r"\percent",
+ )
+ ret[f"error/static/{name}/{attr_name}/mape"] = (
+ e_static["mape"],
+ r"\percent",
+ )
+ ret[f"error/lut/{name}/{attr_name}/mape"] = (e_lut["mape"], r"\percent")
+ ret[f"error/model/{name}/{attr_name}/mape"] = (
+ e_model["mape"],
+ r"\percent",
+ )
+ return ret
+
def to_json(self) -> dict:
"""
Return JSON encoding of this AnalyticModel.