diff options
-rwxr-xr-x | bin/analyze-archive.py | 18 | ||||
-rwxr-xr-x | bin/analyze-timing.py | 6 | ||||
-rwxr-xr-x | bin/eval-outlier-removal.py | 11 | ||||
-rwxr-xr-x | bin/eval-rel-energy.py | 4 | ||||
-rwxr-xr-x | bin/test_corrcoef.py | 6 | ||||
-rw-r--r-- | lib/model.py | 19 | ||||
-rw-r--r-- | lib/validation.py | 14 | ||||
-rwxr-xr-x | test/test_ptamodel.py | 162 |
8 files changed, 106 insertions, 134 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py index e7027ed..582302d 100755 --- a/bin/analyze-archive.py +++ b/bin/analyze-archive.py @@ -91,8 +91,8 @@ def model_quality_table(header, result_lists, info_list): header[2].center(19), ) ) - for state_or_tran in result_lists[0]["by_name"].keys(): - for key in result_lists[0]["by_name"][state_or_tran].keys(): + for state_or_tran in result_lists[0].keys(): + for key in result_lists[0][state_or_tran].keys(): buf = "{:20s} {:15s}".format(state_or_tran, key) for i, results in enumerate(result_lists): info = info_list[i] @@ -112,7 +112,7 @@ def model_quality_table(header, result_lists, info_list): ) ) ): - result = results["by_name"][state_or_tran][key] + result = results[state_or_tran][key] buf += format_quality_measures(result) else: buf += "{:7}----{:8}".format("", "") @@ -226,12 +226,12 @@ def print_html_model_data(raw_data, model, pm, pq, lm, lq, am, ai, aq): unit = "" if attribute == "power": unit = "µW" - static_quality = pq["by_name"][state][attribute]["smape"] + static_quality = pq[state][attribute]["smape"] print( f"* {attribute} mean: {pm(state, attribute):.0f} {unit} (± {static_quality:.1f}%)" ) if ai(state, attribute): - analytic_quality = aq["by_name"][state][attribute]["smape"] + analytic_quality = aq[state][attribute]["smape"] fstr = ai(state, attribute)["function"].model_function fstr = fstr.replace("0 + ", "", 1) for i, marg in enumerate(ai(state, attribute)["function"].model_args): @@ -261,12 +261,12 @@ def print_html_model_data(raw_data, model, pm, pq, lm, lq, am, ai, aq): unit = "µs" elif attribute in ["energy", "rel_energy_prev"]: unit = "pJ" - static_quality = pq["by_name"][trans][attribute]["smape"] + static_quality = pq[trans][attribute]["smape"] print( f"* {attribute} mean: {pm(trans, attribute):.0f} {unit} (± {static_quality:.1f}%)" ) if ai(trans, attribute): - analytic_quality = aq["by_name"][trans][attribute]["smape"] + analytic_quality = aq[trans][attribute]["smape"] fstr = ai(trans, attribute)["function"].model_function fstr = fstr.replace("0 + ", "", 1) for i, marg in enumerate(ai(trans, attribute)["function"].model_args): @@ -288,7 +288,7 @@ def print_html_model_data(raw_data, model, pm, pq, lm, lq, am, ai, aq): unit = "µW" print( "<td>{:.0f} {} ({:.1f}%)</td>".format( - pm(state, attribute), unit, pq["by_name"][state][attribute]["smape"] + pm(state, attribute), unit, pq[state][attribute]["smape"] ), end="", ) @@ -315,7 +315,7 @@ def print_html_model_data(raw_data, model, pm, pq, lm, lq, am, ai, aq): unit = "pJ" print( "<td>{:.0f} {} ({:.1f}%)</td>".format( - pm(trans, attribute), unit, pq["by_name"][trans][attribute]["smape"] + pm(trans, attribute), unit, pq[trans][attribute]["smape"] ), end="", ) diff --git a/bin/analyze-timing.py b/bin/analyze-timing.py index e8af0fb..129b0ff 100755 --- a/bin/analyze-timing.py +++ b/bin/analyze-timing.py @@ -111,14 +111,14 @@ def format_quality_measures(result): def model_quality_table(result_lists, info_list): - for state_or_tran in result_lists[0]["by_name"].keys(): - for key in result_lists[0]["by_name"][state_or_tran].keys(): + for state_or_tran in result_lists[0].keys(): + for key in result_lists[0][state_or_tran].keys(): buf = "{:20s} {:15s}".format(state_or_tran, key) for i, results in enumerate(result_lists): info = info_list[i] buf += " ||| " if info is None or type(info(state_or_tran, key)) is not StaticFunction: - result = results["by_name"][state_or_tran][key] + result = results[state_or_tran][key] buf += format_quality_measures(result) else: buf += "{:6}----{:9}".format("", "") diff --git a/bin/eval-outlier-removal.py b/bin/eval-outlier-removal.py index d6c905c..217d43f 100755 --- a/bin/eval-outlier-removal.py +++ b/bin/eval-outlier-removal.py @@ -10,11 +10,11 @@ opt = dict() def model_quality_table(result_lists, info_list): - for state_or_tran in result_lists[0]["by_name"].keys(): - for key in result_lists[0]["by_name"][state_or_tran].keys(): + for state_or_tran in result_lists[0].keys(): + for key in result_lists[0][state_or_tran].keys(): buf = "{:20s} {:15s}".format(state_or_tran, key) for i, results in enumerate(result_lists): - results = results["by_name"] + results = results info = info_list[i] buf += " ||| " if info == None or info(state_or_tran, key): @@ -31,12 +31,11 @@ def model_quality_table(result_lists, info_list): def combo_model_quality_table(result_lists, info_list): - for state_or_tran in result_lists[0][0]["by_name"].keys(): - for key in result_lists[0][0]["by_name"][state_or_tran].keys(): + for state_or_tran in result_lists[0][0].keys(): + for key in result_lists[0][0][state_or_tran].keys(): for sub_result_lists in result_lists: buf = "{:20s} {:15s}".format(state_or_tran, key) for i, results in enumerate(sub_result_lists): - results = results["by_name"] info = info_list[i] buf += " ||| " if info == None or info(state_or_tran, key): diff --git a/bin/eval-rel-energy.py b/bin/eval-rel-energy.py index cec1576..245746a 100755 --- a/bin/eval-rel-energy.py +++ b/bin/eval-rel-energy.py @@ -92,8 +92,8 @@ if __name__ == "__main__": lut_quality = model.assess(model.get_param_lut()) for trans in model.transitions: - absolute_quality = lut_quality["by_name"][trans]["energy"] - relative_quality = lut_quality["by_name"][trans]["rel_energy_prev"] + absolute_quality = lut_quality[trans]["energy"] + relative_quality = lut_quality[trans]["rel_energy_prev"] if absolute_quality["mae"] < relative_quality["mae"]: best = "absolute" score_absolute += 1 diff --git a/bin/test_corrcoef.py b/bin/test_corrcoef.py index 49944cd..2e21890 100755 --- a/bin/test_corrcoef.py +++ b/bin/test_corrcoef.py @@ -33,14 +33,14 @@ def format_quality_measures(result): def model_quality_table(result_lists, info_list): - for state_or_tran in result_lists[0]["by_name"].keys(): - for key in result_lists[0]["by_name"][state_or_tran].keys(): + for state_or_tran in result_lists[0].keys(): + for key in result_lists[0][state_or_tran].keys(): buf = "{:20s} {:15s}".format(state_or_tran, key) for i, results in enumerate(result_lists): info = info_list[i] buf += " ||| " if info == None or info(state_or_tran, key): - result = results["by_name"][state_or_tran][key] + result = results[state_or_tran][key] buf += format_quality_measures(result) else: buf += "{:6}----{:9}".format("", "") diff --git a/lib/model.py b/lib/model.py index 85cda71..829ca37 100644 --- a/lib/model.py +++ b/lib/model.py @@ -309,15 +309,15 @@ class AnalyticModel: measures = regression_measures(predicted_data, elem[attribute]) detailed_results[name][attribute] = measures - return {"by_name": detailed_results} + return 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] + e_static = static_quality[name][attr_name] + e_lut = lut_quality[name][attr_name] + e_model = model_quality[name][attr_name] unit = None if "power" in attr.attr: unit = r"\micro\watt" @@ -791,9 +791,7 @@ class PTAModel(AnalyticModel): if pta is None: pta = PTA(self.states, parameters=self._parameter_names) pta.update( - param_info, - static_error=static_quality["by_name"], - function_error=analytic_quality["by_name"], + param_info, static_error=static_quality, function_error=analytic_quality ) return pta.to_json() @@ -812,7 +810,7 @@ class PTAModel(AnalyticModel): """ if ref is None: ref = self.by_name - detailed_results = super().assess(model_function, ref=ref)["by_name"] + detailed_results = super().assess(model_function, ref=ref) for name, elem in sorted(ref.items()): if elem["isa"] == "transition": predicted_data = np.array( @@ -831,7 +829,7 @@ class PTAModel(AnalyticModel): ) detailed_results[name]["energy_Pt"] = measures - return {"by_name": detailed_results} + return detailed_results def assess_states( self, model_function, model_attribute="power", distribution: dict = None @@ -861,8 +859,7 @@ class PTAModel(AnalyticModel): sum( map( lambda x: np.square( - model_quality["by_name"][x][model_attribute]["mae"] - * distribution[x] + model_quality[x][model_attribute]["mae"] * distribution[x] ), self.states, ) diff --git a/lib/validation.py b/lib/validation.py index ee147fe..cfd4deb 100644 --- a/lib/validation.py +++ b/lib/validation.py @@ -172,12 +172,12 @@ class CrossValidator: return self._generic_xv(model_getter, training_and_validation_sets) def _generic_xv(self, model_getter, training_and_validation_sets): - ret = {"by_name": dict()} + ret = dict() for name in self.names: - ret["by_name"][name] = dict() + ret[name] = dict() for attribute in self.by_name[name]["attributes"]: - ret["by_name"][name][attribute] = { + ret[name][attribute] = { "mae_list": list(), "rmsd_list": list(), "smape_list": list(), @@ -188,15 +188,15 @@ class CrossValidator: for name in self.names: for attribute in self.by_name[name]["attributes"]: for measure in ("mae", "rmsd", "smape"): - ret["by_name"][name][attribute][f"{measure}_list"].append( - res["by_name"][name][attribute][measure] + ret[name][attribute][f"{measure}_list"].append( + res[name][attribute][measure] ) for name in self.names: for attribute in self.by_name[name]["attributes"]: for measure in ("mae", "rmsd", "smape"): - ret["by_name"][name][attribute][measure] = np.mean( - ret["by_name"][name][attribute][f"{measure}_list"] + ret[name][attribute][measure] = np.mean( + ret[name][attribute][f"{measure}_list"] ) return ret diff --git a/test/test_ptamodel.py b/test/test_ptamodel.py index 9f5076c..9d1b39b 100755 --- a/test/test_ptamodel.py +++ b/test/test_ptamodel.py @@ -142,24 +142,18 @@ class TestSynthetic(unittest.TestCase): # the Root Mean Square Deviation must not be greater the scale (i.e., standard deviation) of the normal distribution # Low Mean Absolute Error (< 2) - self.assertTrue(static_quality["by_name"]["raw_state_1"]["duration"]["mae"] < 2) + self.assertTrue(static_quality["raw_state_1"]["duration"]["mae"] < 2) # Low Root Mean Square Deviation (< scale == 2) - self.assertTrue( - static_quality["by_name"]["raw_state_1"]["duration"]["rmsd"] < 2 - ) + self.assertTrue(static_quality["raw_state_1"]["duration"]["rmsd"] < 2) # Relatively low error percentage (~~ MAE * 100% / s1_duration_base) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["duration"]["mape"], - static_quality["by_name"]["raw_state_1"]["duration"]["mae"] - * 100 - / s1_duration_base, + static_quality["raw_state_1"]["duration"]["mape"], + static_quality["raw_state_1"]["duration"]["mae"] * 100 / s1_duration_base, places=1, ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["duration"]["smape"], - static_quality["by_name"]["raw_state_1"]["duration"]["mae"] - * 100 - / s1_duration_base, + static_quality["raw_state_1"]["duration"]["smape"], + static_quality["raw_state_1"]["duration"]["mae"] * 100 / s1_duration_base, places=1, ) @@ -168,129 +162,121 @@ class TestSynthetic(unittest.TestCase): # MAE == mean(abs(actual value - model value)) # parameter range is [0, 50) -> mean 25, deviation range is [0, 25) -> mean deviation is 12.5 ± gauss scale self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["power"]["mae"], 12.5, delta=1 + static_quality["raw_state_1"]["power"]["mae"], 12.5, delta=1 ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["power"]["rmsd"], 16, delta=2 + static_quality["raw_state_1"]["power"]["rmsd"], 16, delta=2 ) # high percentage error due to low s1_power_base self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["power"]["mape"], 19, delta=2 + static_quality["raw_state_1"]["power"]["mape"], 19, delta=2 ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["power"]["smape"], 19, delta=2 + static_quality["raw_state_1"]["power"]["smape"], 19, delta=2 ) # parameter range is [0, 100) -> mean deviation is 25 ± gauss scale self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["duration"]["mae"], 25, delta=2 + static_quality["raw_state_2"]["duration"]["mae"], 25, delta=2 ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["duration"]["rmsd"], 30, delta=2 + static_quality["raw_state_2"]["duration"]["rmsd"], 30, delta=2 ) # low percentage error due to high s2_duration_base (~~ 3.5 %) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["duration"]["mape"], + static_quality["raw_state_2"]["duration"]["mape"], 25 * 100 / s2_duration_base, delta=1, ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["duration"]["smape"], + static_quality["raw_state_2"]["duration"]["smape"], 25 * 100 / s2_duration_base, delta=1, ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["power"]["mae"], 12.5, delta=2 + static_quality["raw_state_2"]["power"]["mae"], 12.5, delta=2 ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["power"]["rmsd"], 17, delta=2 + static_quality["raw_state_2"]["power"]["rmsd"], 17, delta=2 ) # low percentage error due to high s2_power_base (~~ 1.7 %) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["power"]["mape"], + static_quality["raw_state_2"]["power"]["mape"], 25 * 100 / s2_power_base, delta=1, ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["power"]["smape"], + static_quality["raw_state_2"]["power"]["smape"], 25 * 100 / s2_power_base, delta=1, ) # raw_state_1/duration does not depend on parameters and delegates to the static model self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["duration"]["mae"], - static_quality["by_name"]["raw_state_1"]["duration"]["mae"], + param_quality["raw_state_1"]["duration"]["mae"], + static_quality["raw_state_1"]["duration"]["mae"], ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["duration"]["rmsd"], - static_quality["by_name"]["raw_state_1"]["duration"]["rmsd"], + param_quality["raw_state_1"]["duration"]["rmsd"], + static_quality["raw_state_1"]["duration"]["rmsd"], ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["duration"]["mape"], - static_quality["by_name"]["raw_state_1"]["duration"]["mape"], + param_quality["raw_state_1"]["duration"]["mape"], + static_quality["raw_state_1"]["duration"]["mape"], ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["duration"]["smape"], - static_quality["by_name"]["raw_state_1"]["duration"]["smape"], + param_quality["raw_state_1"]["duration"]["smape"], + static_quality["raw_state_1"]["duration"]["smape"], ) # fitted param-model quality reflects normal distribution scale for all data self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["power"]["mape"], 0.9, places=1 + param_quality["raw_state_2"]["power"]["mape"], 0.9, places=1 ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["power"]["smape"], 0.9, places=1 + param_quality["raw_state_2"]["power"]["smape"], 0.9, places=1 ) - self.assertTrue( - param_quality["by_name"]["raw_state_1"]["power"]["mae"] < s1_power_scale - ) - self.assertTrue( - param_quality["by_name"]["raw_state_1"]["power"]["rmsd"] < s1_power_scale - ) + self.assertTrue(param_quality["raw_state_1"]["power"]["mae"] < s1_power_scale) + self.assertTrue(param_quality["raw_state_1"]["power"]["rmsd"] < s1_power_scale) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["power"]["mape"], 7.5, delta=1 + param_quality["raw_state_1"]["power"]["mape"], 7.5, delta=1 ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["power"]["smape"], 7.5, delta=1 + param_quality["raw_state_1"]["power"]["smape"], 7.5, delta=1 ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["duration"]["mae"], + param_quality["raw_state_2"]["duration"]["mae"], s2_duration_scale, delta=0.2, ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["duration"]["rmsd"], + param_quality["raw_state_2"]["duration"]["rmsd"], s2_duration_scale, delta=0.2, ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["duration"]["mape"], - 0.12, - delta=0.01, + param_quality["raw_state_2"]["duration"]["mape"], 0.12, delta=0.01 ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["duration"]["smape"], - 0.12, - delta=0.01, + param_quality["raw_state_2"]["duration"]["smape"], 0.12, delta=0.01 ) # ... unless the signal-to-noise ratio (parameter range = [0 .. 50] vs. scale = 10) is bad, leading to # increased regression errors - self.assertTrue(param_quality["by_name"]["raw_state_2"]["power"]["mae"] < 15) - self.assertTrue(param_quality["by_name"]["raw_state_2"]["power"]["rmsd"] < 18) + self.assertTrue(param_quality["raw_state_2"]["power"]["mae"] < 15) + self.assertTrue(param_quality["raw_state_2"]["power"]["rmsd"] < 18) # still: low percentage error due to high s2_power_base self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["power"]["mape"], 0.9, places=1 + param_quality["raw_state_2"]["power"]["mape"], 0.9, places=1 ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["power"]["smape"], 0.9, places=1 + param_quality["raw_state_2"]["power"]["smape"], 0.9, places=1 ) def test_model_crossvalidation_10fold(self): @@ -343,17 +329,13 @@ class TestSynthetic(unittest.TestCase): # the Root Mean Square Deviation must not be greater the scale (i.e., standard deviation) of the normal distribution # Low Mean Absolute Error (< 2) - self.assertTrue(static_quality["by_name"]["raw_state_1"]["duration"]["mae"] < 2) + self.assertTrue(static_quality["raw_state_1"]["duration"]["mae"] < 2) # Low Root Mean Square Deviation (< scale == 2) - self.assertTrue( - static_quality["by_name"]["raw_state_1"]["duration"]["rmsd"] < 2 - ) + self.assertTrue(static_quality["raw_state_1"]["duration"]["rmsd"] < 2) # Relatively low error percentage (~~ MAE * 100% / s1_duration_base) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["duration"]["smape"], - static_quality["by_name"]["raw_state_1"]["duration"]["mae"] - * 100 - / s1_duration_base, + static_quality["raw_state_1"]["duration"]["smape"], + static_quality["raw_state_1"]["duration"]["mae"] * 100 / s1_duration_base, places=1, ) @@ -362,98 +344,92 @@ class TestSynthetic(unittest.TestCase): # MAE == mean(abs(actual value - model value)) # parameter range is [0, 50) -> mean 25, deviation range is [0, 25) -> mean deviation is 12.5 ± gauss scale self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["power"]["mae"], 12.5, delta=1 + static_quality["raw_state_1"]["power"]["mae"], 12.5, delta=1 ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["power"]["rmsd"], 16, delta=2 + static_quality["raw_state_1"]["power"]["rmsd"], 16, delta=2 ) # high percentage error due to low s1_power_base self.assertAlmostEqual( - static_quality["by_name"]["raw_state_1"]["power"]["smape"], 19, delta=2 + static_quality["raw_state_1"]["power"]["smape"], 19, delta=2 ) # parameter range is [0, 100) -> mean deviation is 25 ± gauss scale self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["duration"]["mae"], 25, delta=2 + static_quality["raw_state_2"]["duration"]["mae"], 25, delta=2 ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["duration"]["rmsd"], 30, delta=2 + static_quality["raw_state_2"]["duration"]["rmsd"], 30, delta=2 ) # low percentage error due to high s2_duration_base (~~ 3.5 %) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["duration"]["smape"], + static_quality["raw_state_2"]["duration"]["smape"], 25 * 100 / s2_duration_base, delta=1, ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["power"]["mae"], 12.5, delta=2 + static_quality["raw_state_2"]["power"]["mae"], 12.5, delta=2 ) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["power"]["rmsd"], 17, delta=2 + static_quality["raw_state_2"]["power"]["rmsd"], 17, delta=2 ) # low percentage error due to high s2_power_base (~~ 1.7 %) self.assertAlmostEqual( - static_quality["by_name"]["raw_state_2"]["power"]["smape"], + static_quality["raw_state_2"]["power"]["smape"], 25 * 100 / s2_power_base, delta=1, ) # raw_state_1/duration does not depend on parameters and delegates to the static model self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["duration"]["mae"], - static_quality["by_name"]["raw_state_1"]["duration"]["mae"], + param_quality["raw_state_1"]["duration"]["mae"], + static_quality["raw_state_1"]["duration"]["mae"], ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["duration"]["rmsd"], - static_quality["by_name"]["raw_state_1"]["duration"]["rmsd"], + param_quality["raw_state_1"]["duration"]["rmsd"], + static_quality["raw_state_1"]["duration"]["rmsd"], ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["duration"]["smape"], - static_quality["by_name"]["raw_state_1"]["duration"]["smape"], + param_quality["raw_state_1"]["duration"]["smape"], + static_quality["raw_state_1"]["duration"]["smape"], ) # fitted param-model quality reflects normal distribution scale for all data self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["power"]["smape"], 0.9, places=1 + param_quality["raw_state_2"]["power"]["smape"], 0.9, places=1 ) - self.assertTrue( - param_quality["by_name"]["raw_state_1"]["power"]["mae"] < s1_power_scale - ) - self.assertTrue( - param_quality["by_name"]["raw_state_1"]["power"]["rmsd"] < s1_power_scale - ) + self.assertTrue(param_quality["raw_state_1"]["power"]["mae"] < s1_power_scale) + self.assertTrue(param_quality["raw_state_1"]["power"]["rmsd"] < s1_power_scale) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_1"]["power"]["smape"], 7.5, delta=1 + param_quality["raw_state_1"]["power"]["smape"], 7.5, delta=1 ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["duration"]["mae"], + param_quality["raw_state_2"]["duration"]["mae"], s2_duration_scale, delta=0.2, ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["duration"]["rmsd"], + param_quality["raw_state_2"]["duration"]["rmsd"], s2_duration_scale, delta=0.2, ) self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["duration"]["smape"], - 0.12, - delta=0.01, + param_quality["raw_state_2"]["duration"]["smape"], 0.12, delta=0.01 ) # ... unless the signal-to-noise ratio (parameter range = [0 .. 50] vs. scale = 10) is bad, leading to # increased regression errors - self.assertTrue(param_quality["by_name"]["raw_state_2"]["power"]["mae"] < 15) - self.assertTrue(param_quality["by_name"]["raw_state_2"]["power"]["rmsd"] < 18) + self.assertTrue(param_quality["raw_state_2"]["power"]["mae"] < 15) + self.assertTrue(param_quality["raw_state_2"]["power"]["rmsd"] < 18) # still: low percentage error due to high s2_power_base self.assertAlmostEqual( - param_quality["by_name"]["raw_state_2"]["power"]["smape"], 0.9, places=1 + param_quality["raw_state_2"]["power"]["smape"], 0.9, places=1 ) |