From fd159f218cb8da0f58f6fe350dc55853bb395a5f Mon Sep 17 00:00:00 2001 From: Stefan Heid Date: Mon, 12 Feb 2024 17:37:32 +0100 Subject: [PATCH 1/2] Update beta_calibration.py --- betacal/beta_calibration.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/betacal/beta_calibration.py b/betacal/beta_calibration.py index e8208e7..bdabc9d 100644 --- a/betacal/beta_calibration.py +++ b/betacal/beta_calibration.py @@ -30,7 +30,7 @@ def _beta_calibration(df, y, sample_weight=None): lr = LogisticRegression(C=99999999999) lr.fit(x, y, sample_weight) coefs = lr.coef_[0] - a = 0 + a = None b = coefs[0] elif coefs[1] < 0: x = x[:, 0].reshape(-1, 1) @@ -38,7 +38,7 @@ def _beta_calibration(df, y, sample_weight=None): lr.fit(x, y, sample_weight) coefs = lr.coef_[0] a = coefs[0] - b = 0 + b = None else: a = coefs[0] b = coefs[1] @@ -112,9 +112,9 @@ def predict(self, S): x = np.hstack((df, 1. - df)) x = np.log(x) x[:, 1] *= -1 - if self.map_[0] == 0: + if self.map_[0] == None: x = x[:, 1].reshape(-1, 1) - elif self.map_[1] == 0: + elif self.map_[1] == None: x = x[:, 0].reshape(-1, 1) return self.lr_.predict_proba(x)[:, 1] From d20b05063dadb6fcfd208bf3cf7fa5f3abfa5421 Mon Sep 17 00:00:00 2001 From: Stefan Heid Date: Mon, 12 Feb 2024 17:43:30 +0100 Subject: [PATCH 2/2] Update beta_calibration.py --- betacal/beta_calibration.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/betacal/beta_calibration.py b/betacal/beta_calibration.py index bdabc9d..2ff89c6 100644 --- a/betacal/beta_calibration.py +++ b/betacal/beta_calibration.py @@ -44,7 +44,8 @@ def _beta_calibration(df, y, sample_weight=None): b = coefs[1] inter = lr.intercept_[0] - m = minimize_scalar(lambda mh: np.abs(b*np.log(1.-mh)-a*np.log(mh)-inter), + a_, b_ = a or 0, b or 0 + m = minimize_scalar(lambda mh: np.abs(b_*np.log(1.-mh)-a_*np.log(mh)-inter), bounds=[0, 1], method='Bounded').x map = [a, b, m] return map, lr