From 142efa984c9d7d8828e8067ce8849bb950614bd2 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 20 Aug 2021 15:41:53 +0200 Subject: model/dtree generation: detect int parameters, do not hardcode "batch_size" --- lib/model.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/model.py b/lib/model.py index 3595e28..f43d6a2 100644 --- a/lib/model.py +++ b/lib/model.py @@ -377,8 +377,12 @@ class AnalyticModel: mean_stds.append(np.inf) continue - # temporary hack for ResKIL / kconfig-webconf evaluation of regression trees with function nodes - if with_function_leaves and param == "batch_size": + if ( + with_function_leaves + and len(unique_values) > 3 + and all(map(lambda x: type(x) is int, unique_values)) + ): + # param can be modeled as a function. Do not split on it. mean_stds.append(np.inf) continue @@ -409,8 +413,8 @@ class AnalyticModel: if np.all(np.isinf(mean_stds)): # all children have the same configuration. We shouldn't get here due to the threshold check above... - # temporary hack for ResKIL / kconfig-webconf evaluation of regression trees with function nodes - if with_function_leaves and "batch_size" in parameter_names: + if with_function_leaves: + # try generating a function. if it fails, model_function is a StaticFunction. ma = ModelAttribute("tmp", "tmp", data, parameters, self.parameters, 0) ParamStats.compute_for_attr(ma) paramfit = ParamFit(parallel=False) @@ -418,8 +422,6 @@ class AnalyticModel: paramfit.enqueue(key, param, args, kwargs) paramfit.fit() ma.set_data_from_paramfit(paramfit) - print(ma) - print(ma.model_function) return ma.model_function else: logging.warning( -- cgit v1.2.3