@@ -202,8 +202,8 @@ class ITML_Supervised(_BaseITML, TransformerMixin):
202
202
"""
203
203
204
204
def __init__ (self , gamma = 1. , max_iter = 1000 , convergence_threshold = 1e-3 ,
205
- num_labeled = 'deprecated' , num_constraints = None , bounds = None ,
206
- A0 = None , verbose = False , preprocessor = None ):
205
+ num_labeled = 'deprecated' , num_constraints = None ,
206
+ bounds = 'deprecated' , A0 = None , verbose = False , preprocessor = None ):
207
207
"""Initialize the supervised version of `ITML`.
208
208
209
209
`ITML_Supervised` creates pairs of similar sample by taking same class
@@ -222,14 +222,11 @@ def __init__(self, gamma=1., max_iter=1000, convergence_threshold=1e-3,
222
222
be removed in 0.6.0.
223
223
num_constraints: int, optional
224
224
number of constraints to generate
225
- bounds : `list` of two numbers
226
- Bounds on similarity, aside slack variables, s.t.
227
- ``d(a, b) < bounds_[0]`` for all given pairs of similar points ``a``
228
- and ``b``, and ``d(c, d) > bounds_[1]`` for all given pairs of
229
- dissimilar points ``c`` and ``d``, with ``d`` the learned distance.
230
- If not provided at initialization, bounds_[0] and bounds_[1] will be
231
- set to the 5th and 95th percentile of the pairwise distances among all
232
- points in the training data `X`.
225
+ bounds : Not used
226
+ .. deprecated:: 0.5.0
227
+ `bounds` was deprecated in version 0.5.0 and will
228
+ be removed in 0.6.0. Set `bounds` at fit time instead :
229
+ `itml_supervised.fit(X, y, bounds=...)`
233
230
A0 : (d x d) matrix, optional
234
231
initial regularization matrix, defaults to identity
235
232
verbose : bool, optional
@@ -245,7 +242,7 @@ def __init__(self, gamma=1., max_iter=1000, convergence_threshold=1e-3,
245
242
self .num_constraints = num_constraints
246
243
self .bounds = bounds
247
244
248
- def fit (self , X , y , random_state = np .random ):
245
+ def fit (self , X , y , random_state = np .random , bounds = None ):
249
246
"""Create constraints from labels and learn the ITML model.
250
247
251
248
@@ -259,11 +256,26 @@ def fit(self, X, y, random_state=np.random):
259
256
260
257
random_state : numpy.random.RandomState, optional
261
258
If provided, controls random number generation.
259
+
260
+ bounds : `list` of two numbers
261
+ Bounds on similarity, aside slack variables, s.t.
262
+ ``d(a, b) < bounds_[0]`` for all given pairs of similar points ``a``
263
+ and ``b``, and ``d(c, d) > bounds_[1]`` for all given pairs of
264
+ dissimilar points ``c`` and ``d``, with ``d`` the learned distance.
265
+ If not provided at initialization, bounds_[0] and bounds_[1] will be
266
+ set to the 5th and 95th percentile of the pairwise distances among all
267
+ points in the training data `X`.
262
268
"""
269
+ # TODO: remove these in v0.6.0
263
270
if self .num_labeled != 'deprecated' :
264
271
warnings .warn ('"num_labeled" parameter is not used.'
265
272
' It has been deprecated in version 0.5.0 and will be'
266
273
'removed in 0.6.0' , DeprecationWarning )
274
+ if self .bounds != 'deprecated' :
275
+ warnings .warn ('"bounds" parameter from initialization is not used.'
276
+ ' It has been deprecated in version 0.5.0 and will be'
277
+ 'removed in 0.6.0. Use the "bounds" parameter of this '
278
+ 'fit method instead.' , DeprecationWarning )
267
279
X , y = self ._prepare_inputs (X , y , ensure_min_samples = 2 )
268
280
num_constraints = self .num_constraints
269
281
if num_constraints is None :
@@ -274,4 +286,4 @@ def fit(self, X, y, random_state=np.random):
274
286
pos_neg = c .positive_negative_pairs (num_constraints ,
275
287
random_state = random_state )
276
288
pairs , y = wrap_pairs (X , pos_neg )
277
- return _BaseITML ._fit (self , pairs , y , bounds = self . bounds )
289
+ return _BaseITML ._fit (self , pairs , y , bounds = bounds )
0 commit comments