18
18
19
19
from .base import BaseEstimator , ClassifierMixin , RegressorMixin , clone
20
20
from .preprocessing import LabelBinarizer
21
- from .utils import check_random_state
22
21
from .utils import check_X_y , check_array , indexable , column_or_1d
23
22
from .utils .validation import check_is_fitted
24
23
from .isotonic import IsotonicRegression
@@ -59,9 +58,6 @@ class CalibratedClassifierCV(BaseEstimator, ClassifierMixin):
59
58
If "prefit" is passed, it is assumed that base_estimator has been
60
59
fitted already and all data is used for calibration.
61
60
62
- random_state : int, RandomState instance or None (default=None)
63
- Used to randomly break ties when method is 'isotonic'.
64
-
65
61
Attributes
66
62
----------
67
63
classes_ : array, shape (n_classes)
@@ -86,12 +82,10 @@ class CalibratedClassifierCV(BaseEstimator, ClassifierMixin):
86
82
.. [4] Predicting Good Probabilities with Supervised Learning,
87
83
A. Niculescu-Mizil & R. Caruana, ICML 2005
88
84
"""
89
- def __init__ (self , base_estimator = None , method = 'sigmoid' , cv = 3 ,
90
- random_state = None ):
85
+ def __init__ (self , base_estimator = None , method = 'sigmoid' , cv = 3 ):
91
86
self .base_estimator = base_estimator
92
87
self .method = method
93
88
self .cv = cv
94
- self .random_state = random_state
95
89
96
90
def fit (self , X , y , sample_weight = None ):
97
91
"""Fit the calibrated model
@@ -116,7 +110,6 @@ def fit(self, X, y, sample_weight=None):
116
110
X , y = indexable (X , y )
117
111
lb = LabelBinarizer ().fit (y )
118
112
self .classes_ = lb .classes_
119
- random_state = check_random_state (self .random_state )
120
113
121
114
# Check that we each cross-validation fold can have at least one
122
115
# example per class
@@ -136,7 +129,7 @@ def fit(self, X, y, sample_weight=None):
136
129
137
130
if self .cv == "prefit" :
138
131
calibrated_classifier = _CalibratedClassifier (
139
- base_estimator , method = self .method , random_state = random_state )
132
+ base_estimator , method = self .method )
140
133
if sample_weight is not None :
141
134
calibrated_classifier .fit (X , y , sample_weight )
142
135
else :
@@ -164,8 +157,7 @@ def fit(self, X, y, sample_weight=None):
164
157
this_estimator .fit (X [train ], y [train ])
165
158
166
159
calibrated_classifier = _CalibratedClassifier (
167
- this_estimator , method = self .method ,
168
- random_state = random_state )
160
+ this_estimator , method = self .method )
169
161
if sample_weight is not None :
170
162
calibrated_classifier .fit (X [test ], y [test ],
171
163
sample_weight [test ])
@@ -242,9 +234,6 @@ class _CalibratedClassifier(object):
242
234
corresponds to Platt's method or 'isotonic' which is a
243
235
non-parameteric approach based on isotonic regression.
244
236
245
- random_state : int, RandomState instance or None (default=None)
246
- Used to randomly break ties when method is 'isotonic'.
247
-
248
237
References
249
238
----------
250
239
.. [1] Obtaining calibrated probability estimates from decision trees
@@ -259,11 +248,9 @@ class _CalibratedClassifier(object):
259
248
.. [4] Predicting Good Probabilities with Supervised Learning,
260
249
A. Niculescu-Mizil & R. Caruana, ICML 2005
261
250
"""
262
- def __init__ (self , base_estimator , method = 'sigmoid' ,
263
- random_state = None ):
251
+ def __init__ (self , base_estimator , method = 'sigmoid' ):
264
252
self .base_estimator = base_estimator
265
253
self .method = method
266
- self .random_state = random_state
267
254
268
255
def _preproc (self , X ):
269
256
n_classes = len (self .classes_ )
@@ -312,13 +299,6 @@ def fit(self, X, y, sample_weight=None):
312
299
for k , this_df in zip (idx_pos_class , df .T ):
313
300
if self .method == 'isotonic' :
314
301
calibrator = IsotonicRegression (out_of_bounds = 'clip' )
315
- # XXX: isotonic regression cannot deal correctly with
316
- # situations in which multiple inputs are identical but
317
- # have different outputs. Since this is not untypical
318
- # when calibrating, we add some small random jitter to
319
- # the inputs.
320
- jitter = self .random_state .normal (0 , 1e-10 , this_df .shape [0 ])
321
- this_df = this_df + jitter
322
302
elif self .method == 'sigmoid' :
323
303
calibrator = _SigmoidCalibration ()
324
304
else :
0 commit comments