|
5 | 5 | import numpy as np |
6 | 6 | import pandas as pd |
7 | 7 | import scipy.stats as stats |
| 8 | +import sklearn |
8 | 9 | from numba import njit, prange |
9 | 10 | from sklearn.linear_model import RidgeClassifierCV |
10 | 11 | from sklearn.preprocessing import MinMaxScaler |
11 | 12 |
|
12 | 13 | from .base import BaseThresholder |
13 | 14 |
|
| 15 | +_NEEDS_CLASSES = tuple(map(int, sklearn.__version__.split('.')[:2])) >= (1, 8) |
| 16 | + |
14 | 17 |
|
15 | 18 | class META(BaseThresholder): |
16 | 19 | r"""META class for Meta-modelling thresholder. |
@@ -115,14 +118,11 @@ def eval(self, decision): |
115 | 118 | parent = up(up(__file__)) |
116 | 119 | model = joblib.load(os.path.join(parent, 'models', clf)) |
117 | 120 |
|
118 | | - def _patch_ridge(est): |
119 | | - if isinstance(est, RidgeClassifierCV) and not hasattr(est, 'classes_'): |
120 | | - est.classes_ = np.array([0, 1]) |
121 | | - |
| 121 | + # Sklearn 1.8.0 API patch |
122 | 122 | for e in getattr(model, 'estimators_', {}).values(): |
123 | | - _patch_ridge(e) |
| 123 | + self._patch_ridge(e) |
124 | 124 |
|
125 | | - _patch_ridge(getattr(model, 'estimator', None)) |
| 125 | + self._patch_ridge(getattr(model, 'estimator', None)) |
126 | 126 |
|
127 | 127 | if self.method == 'GNBM': |
128 | 128 |
|
@@ -184,6 +184,12 @@ def _patch_ridge(est): |
184 | 184 |
|
185 | 185 | return lbls |
186 | 186 |
|
| 187 | + @staticmethod |
| 188 | + def _patch_ridge(est): |
| 189 | + """RidgeClassifierCV classes_ attribute patch.""" |
| 190 | + if _NEEDS_CLASSES and isinstance(est, RidgeClassifierCV) and not hasattr(est, 'classes_'): |
| 191 | + est.classes_ = np.array([0, 1]) |
| 192 | + |
187 | 193 | @staticmethod |
188 | 194 | @njit(fastmath=True, parallel=True) |
189 | 195 | def _wrap_around_discrepancy(data, check): |
|
0 commit comments