diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/functions.py | 28 | ||||
-rw-r--r-- | lib/model.py | 2 | ||||
-rw-r--r-- | lib/parameters.py | 3 |
3 files changed, 20 insertions, 13 deletions
diff --git a/lib/functions.py b/lib/functions.py index 38b8b38..a23a995 100644 --- a/lib/functions.py +++ b/lib/functions.py @@ -220,6 +220,9 @@ class ModelFunction: } return ret + def hyper_to_dref(self): + return dict() + @classmethod def from_json(cls, data): """ @@ -737,15 +740,15 @@ class XGBoostFunction(SKLearnRegressionFunction): def get_complexity_score(self): return self.get_number_of_nodes() - def to_dref(self): + def hyper_to_dref(self): return { - "xgb hyper/n estimators": self.regressor.n_estimators, - "xgb hyper/max depth": self.regressor.max_depth, - "xgb hyper/subsample": self.regressor.subsample, - "xgb hyper/eta": self.regressor.learning_rate, - "xgb hyper/gamma": self.regressor.gamma, - "xgb hyper/alpha": self.regressor.reg_alpha, - "xgb hyper/lambda": self.regressor.reg_lambda, + "xgb/n estimators": self.regressor.n_estimators, + "xgb/max depth": self.regressor.max_depth, + "xgb/subsample": self.regressor.subsample, + "xgb/eta": self.regressor.learning_rate, + "xgb/gamma": self.regressor.gamma, + "xgb/alpha": self.regressor.reg_alpha, + "xgb/lambda": self.regressor.reg_lambda, } @@ -760,14 +763,14 @@ class FOLFunction(ModelFunction): self.fit_success = False def fit(self, param_values, data, ignore_param_indexes=None): - categorial_to_scalar = bool( + self.categorial_to_scalar = bool( int(os.getenv("DFATOOL_PARAM_CATEGORIAL_TO_SCALAR", "0")) ) second_order = int(os.getenv("DFATOOL_FOL_SECOND_ORDER", "0")) fit_parameters, categorial_to_index, ignore_index = param_to_ndarray( param_values, with_nan=False, - categorial_to_scalar=categorial_to_scalar, + categorial_to_scalar=self.categorial_to_scalar, ignore_indexes=ignore_param_indexes, ) self.categorial_to_index = categorial_to_index @@ -905,6 +908,11 @@ class FOLFunction(ModelFunction): ) return ret + def hyper_to_dref(self): + return { + "fol/categorial to scalar": int(self.categorial_to_scalar), + } + class AnalyticFunction(ModelFunction): """ diff --git a/lib/model.py b/lib/model.py index 8f93bd3..309e6f5 100644 --- a/lib/model.py +++ b/lib/model.py @@ -499,6 +499,8 @@ class AnalyticModel: unit = r"\micro\second" for k, v in attr.to_dref(unit).items(): ret[f"data/{name}/{attr_name}/{k}"] = v + for k, v in attr.model_function.hyper_to_dref().items(): + ret[f"hyper/{name}/{attr_name}/{k}"] = v e_static = static_quality[name][attr_name] for metric in "mae p50 p90 p95 p99".split(): ret[f"error/static/{name}/{attr_name}/{metric}"] = ( diff --git a/lib/parameters.py b/lib/parameters.py index a101dca..e697eda 100644 --- a/lib/parameters.py +++ b/lib/parameters.py @@ -694,9 +694,6 @@ class ModelAttribute: ret["decision tree/inner nodes"] = 0 ret["decision tree/max depth"] = 0 - if type(self.model_function) == df.XGBoostFunction: - ret.update(self.model_function.to_dref()) - return ret def to_dot(self): |