diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-12-12 18:21:08 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-12-12 18:21:08 +0100 |
commit | 54cb9c0f47b17c57e30c9b8e2b0feb9f11623a09 (patch) | |
tree | 89270f88fc1247cc8be418d6cd77a3cd975bfd0f /lib | |
parent | 50606967e2ae749bf9ab3fa213a7da6e89b0aeed (diff) |
Support lower regression bounds other than -∞
DFATOOL_ULS_MIN_BOUND=0 is especially useful in many cases
Diffstat (limited to 'lib')
-rw-r--r-- | lib/functions.py | 15 | ||||
-rw-r--r-- | lib/paramfit.py | 3 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/functions.py b/lib/functions.py index ae8283a..187e6ff 100644 --- a/lib/functions.py +++ b/lib/functions.py @@ -27,6 +27,8 @@ dfatool_rmt_relevance_threshold = float( os.getenv("DFATOOL_RMT_RELEVANCE_THRESHOLD", "0.5") ) +dfatool_uls_min_bound = float(os.getenv("DFATOOL_ULS_MIN_BOUND", -np.inf)) + if dfatool_preproc_relevance_method == "mi": import sklearn.feature_selection @@ -97,7 +99,7 @@ class ParamFunction: num_vars, repr_str=None, ini=None, - bounds=((-np.inf, -np.inf), (np.inf, np.inf)), + bounds=((dfatool_uls_min_bound, dfatool_uls_min_bound), (np.inf, np.inf)), ): """ Create function object suitable for regression analysis. @@ -1927,7 +1929,7 @@ class AnalyticFunction(ModelFunction): upper_bounds.append(np.max(X[param_index])) self.model_args[i] = np.mean(X[param_index]) else: - lower_bounds.append(-np.inf) + lower_bounds.append(dfatool_uls_min_bound) upper_bounds.append(np.inf) error_function = lambda P, X, y: self._function(P, X) - y try: @@ -2144,7 +2146,14 @@ class analytic: lambda model_param: True, 3, repr_str="β₀ + β₁ * roofline(x, β₂)", - bounds=((-np.inf, -np.inf, -np.inf), (np.inf, np.inf, np.inf)), + bounds=( + ( + dfatool_uls_min_bound, + dfatool_uls_min_bound, + dfatool_uls_min_bound, + ), + (np.inf, np.inf, np.inf), + ), ), # "num0_8": ParamFunction( # lambda reg_param, model_param: reg_param[0] diff --git a/lib/paramfit.py b/lib/paramfit.py index 05ffb86..000aa9c 100644 --- a/lib/paramfit.py +++ b/lib/paramfit.py @@ -17,6 +17,7 @@ from .utils import ( logger = logging.getLogger(__name__) best_fit_metric = os.getenv("DFATOOL_ULS_ERROR_METRIC", "ssr") +dfatool_uls_min_bound = float(os.getenv("DFATOOL_ULS_MIN_BOUND", -np.inf)) class ParamFit: @@ -211,7 +212,7 @@ def _try_fits( ini = [0] + [1 for i in range(1, param_function._num_variables)] if function_name == "roofline": param_function.bounds = ( - (-np.inf, -np.inf, np.min(X)), + (dfatool_uls_min_bound, dfatool_uls_min_bound, np.min(X)), (np.inf, np.inf, np.max(X)), ) ini[2] = np.mean(X) |