diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | lib/functions.py | 8 |
2 files changed, 8 insertions, 1 deletions
@@ -35,3 +35,4 @@ The following variables may be set to alter the behaviour of dfatool components. | `DFATOOL_KCONF_IGNORE_NUMERIC` | **0**, 1 | Ignore numeric (int/hex) configuration options. Useful for comparison with CART/DECART. | | `DFATOOL_KCONF_IGNORE_STRING` | **0**, 1 | Ignore string configuration options. Useful for comparison with CART/DECART. | | `DFATOOL_FIT_LINEAR_ONLY` | **0**, 1 | Only consider linear functions (a + bx) in regression analysis. Useful for comparison with Linear Model Trees / M5. | +| `DFATOOL_REGRESSION_SAFE_FUNCTIONS` | **0**, 1 | Use safe functions only (e.g. 1/x returnning 1 for x==0) | diff --git a/lib/functions.py b/lib/functions.py index 7cd06c0..0a488dc 100644 --- a/lib/functions.py +++ b/lib/functions.py @@ -740,19 +740,25 @@ class analytic: # ), } - if safe_functions_enabled: + if safe_functions_enabled or bool( + int(os.getenv("DFATOOL_REGRESSION_SAFE_FUNCTIONS", "0")) + ): + functions.pop("logarithmic1") + functions.pop("logarithmic") functions["safe_log"] = ParamFunction( lambda reg_param, model_param: reg_param[0] + reg_param[1] * analytic._safe_log(model_param), lambda model_param: True, 2, ) + functions.pop("inverse") functions["safe_inv"] = ParamFunction( lambda reg_param, model_param: reg_param[0] + reg_param[1] * analytic._safe_inv(model_param), lambda model_param: True, 2, ) + functions.pop("sqrt") functions["safe_sqrt"] = ParamFunction( lambda reg_param, model_param: reg_param[0] + reg_param[1] * analytic._safe_sqrt(model_param), |