summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-02-07 18:13:34 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-02-07 18:13:34 +0100
commit2b479dc993b1d73d236d96a4d57bb69159b1603e (patch)
treecc927249f67ca3d840672ea4da1f8d5ffb5f58dd
parentc74ad5b4670d1490135ec5c376559287d9990764 (diff)
AnalyticModel: Calculate by_param from by_name
-rwxr-xr-xlib/dfatool.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py
index 42adfc7..e9af2af 100755
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -225,6 +225,27 @@ class KeysightCSV:
currents[i] = float(row[2]) * -1
return timestamps, currents
+def by_name_to_by_param(by_name):
+ """
+ Convert aggregation by name to aggregation by name and parameter values.
+ """
+ by_param = dict()
+ for name in by_name.keys():
+ for i, parameters in enumerate(by_name[name]['param']):
+ param_key = (name, tuple(parameters))
+ if param_key not in by_param:
+ by_param[param_key] = dict()
+ for key in by_name[name].keys():
+ by_param[param_key][key] = list()
+ by_param[param_key]['attributes'] = by_name[name]['attributes']
+ # special case for PTA models
+ if 'isa' in by_name[name]:
+ by_param[param_key]['isa'] = by_name[name]['isa']
+ for attribute in by_name[name]['attributes']:
+ by_param[param_key][attribute].append(by_name[name][attribute][i])
+ return by_param
+
+
def _xv_partitions_kfold(length, num_slices):
pairs = []
indexes = np.arange(length)
@@ -812,11 +833,11 @@ class AnalyticModel:
assess -- calculate model quality
"""
- def __init__(self, by_name, by_param, parameters, verbose = True):
+ def __init__(self, by_name, parameters, verbose = True):
"""Create a new AnalyticModel and compute parameter statistics."""
self.cache = dict()
self.by_name = by_name
- self.by_param = by_param
+ self.by_param = by_name_to_by_param(by_name)
self.names = sorted(by_name.keys())
self.parameters = sorted(parameters)
self.verbose = verbose