6
6
from .base_metric import _PairsClassifierMixin , MahalanobisMixin
7
7
from .constraints import Constraints , wrap_pairs
8
8
from ._util import components_from_metric , _initialize_metric_mahalanobis
9
+ import warnings
9
10
10
11
11
12
class _BaseMMC (MahalanobisMixin ):
@@ -518,6 +519,8 @@ class MMC_Supervised(_BaseMMC, TransformerMixin):
518
519
Mahalanobis matrix. In any case, `random_state` is also used to
519
520
randomly sample constraints from labels.
520
521
522
+ num_constraints : Renamed to n_constraints. Will be deprecated in 0.7.0
523
+
521
524
Examples
522
525
--------
523
526
>>> from metric_learn import MMC_Supervised
@@ -541,13 +544,23 @@ class MMC_Supervised(_BaseMMC, TransformerMixin):
541
544
def __init__ (self , max_iter = 100 , max_proj = 10000 , tol = 1e-6 ,
542
545
n_constraints = None , init = 'identity' ,
543
546
diagonal = False , diagonal_c = 1.0 , verbose = False ,
544
- preprocessor = None , random_state = None ):
547
+ preprocessor = None , random_state = None ,
548
+ num_constraints = 'deprecated' ):
545
549
_BaseMMC .__init__ (self , max_iter = max_iter , max_proj = max_proj ,
546
550
tol = tol ,
547
551
init = init , diagonal = diagonal ,
548
552
diagonal_c = diagonal_c , verbose = verbose ,
549
553
preprocessor = preprocessor , random_state = random_state )
550
- self .n_constraints = n_constraints
554
+ if num_constraints != 'deprecated' :
555
+ warnings .warn ('"num_constraints" parameter has been renamed to'
556
+ ' "n_constraints". It has been deprecated in'
557
+ ' version 0.6.3 and will be removed in 0.7.0'
558
+ '' , FutureWarning )
559
+ self .n_constraints = num_constraints
560
+ else :
561
+ self .n_constraints = n_constraints
562
+ # Avoid test get_params from failing (all params passed sholud be set)
563
+ self .num_constraints = 'deprecated'
551
564
552
565
def fit (self , X , y ):
553
566
"""Create constraints from labels and learn the MMC model.
0 commit comments