Skip to content

Commit ac8fa2a

Browse files
committed
Sklearn API changes fix test 1
1 parent a2264c2 commit ac8fa2a

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

pythresh/thresholds/comb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def fit(self, X, y):
192192

193193
self.models = []
194194
self.priors = []
195-
self.classes_ = [0, 1]
195+
self.classes_ = np.array([0, 1])
196196
dist = [stats.laplace, stats.norm]
197197

198198
for c in self.classes_:

pythresh/thresholds/meta.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pandas as pd
77
import scipy.stats as stats
88
from numba import njit, prange
9+
from sklearn.linear_model import RidgeClassifierCV
910
from sklearn.preprocessing import MinMaxScaler
1011

1112
from .base import BaseThresholder
@@ -114,6 +115,15 @@ def eval(self, decision):
114115
parent = up(up(__file__))
115116
model = joblib.load(os.path.join(parent, 'models', clf))
116117

118+
def _patch_ridge(est):
119+
if isinstance(est, RidgeClassifierCV) and not hasattr(est, 'classes_'):
120+
est.classes_ = np.array([0, 1])
121+
122+
for e in getattr(model, 'estimators_', {}).values():
123+
_patch_ridge(e)
124+
125+
_patch_ridge(getattr(model, 'estimator', None))
126+
117127
if self.method == 'GNBM':
118128

119129
if self._scaler is None:

0 commit comments

Comments
 (0)