class_docstr: Supervised version of Mahalanobis Metric for Clustering (MMC)
  
  `MMC_Supervised` creates pairs of similar sample by taking same class
  samples, and pairs of dissimilar samples by taking different class
  samples. It then passes these pairs to `MMC` for training.
  
  Parameters
  ----------
  max_iter : int, optional (default=100)
    Maximum number of iterations of the optimization procedure.
  
  max_proj : int, optional (default=10000)
    Maximum number of projection steps.
  
  tol : float, optional (default=1e-3)
    Convergence threshold for the optimization procedure.
  
  n_constraints: int, optional (default=None)
    Number of constraints to generate. If None, default to `20 *
    num_classes**2`.
  
  init : string or numpy array, optional (default='identity')
    Initialization of the Mahalanobis matrix. Possible options are
    'identity', 'covariance', 'random', and a numpy array of
    shape (n_features, n_features).
  
    'identity'
      An identity matrix of shape (n_features, n_features).
  
    'covariance'
      The (pseudo-)inverse of the covariance matrix.
  
    'random'
      The initial Mahalanobis matrix will be a random SPD matrix of
      shape `(n_features, n_features)`, generated using
      `sklearn.datasets.make_spd_matrix`.
  
    numpy array
      A numpy array of shape (n_features, n_features), that will
      be used as such to initialize the metric.
  
  diagonal : bool, optional (default=False)
    If True, a diagonal metric will be learned,
    i.e., a simple scaling of dimensions. The initialization will then
    be the diagonal coefficients of the matrix given as 'init'.
  
  diagonal_c : float, optional (default=1.0)
    Weight of the dissimilarity constraint for diagonal
    metric learning. Ignored if ``diagonal=False``.
  
  verbose : bool, optional (default=False)
    If True, prints information while learning
  
  preprocessor : array-like, shape=(n_samples, n_features) or callable
    The preprocessor to call to get tuples from indices. If array-like,
    tuples will be formed like this: X[indices].
  
  random_state : int or numpy.RandomState or None, optional (default=None)
    A pseudo random number generator object or a seed for it if int. If
    ``init='random'``, ``random_state`` is used to initialize the random
    Mahalanobis matrix.  In any case, `random_state` is also used to
    randomly sample constraints from labels.
  
  num_constraints : Renamed to n_constraints. Will be deprecated in 0.7.0
  
  convergence_threshold : Renamed to tol. Will be deprecated in 0.7.0
  
  Examples
  --------
  >>> from metric_learn import MMC_Supervised
  >>> from sklearn.datasets import load_iris
  >>> iris_data = load_iris()
  >>> X = iris_data['data']
  >>> Y = iris_data['target']
  >>> mmc = MMC_Supervised(n_constraints=200)
  >>> mmc.fit(X, Y)
  
  Attributes
  ----------
  n_iter_ : `int`
    The number of iterations the solver has run.
  
  components_ : `numpy.ndarray`, shape=(n_features, n_features)
    The linear transformation ``L`` deduced from the learned Mahalanobis
    metric (See function `components_from_metric`.)
class_docstr_tok: ["Supervised","version","of","Mahalanobis","Metric","for","Clustering","(","MMC",")","`","MMC_Supervised","`","creates","pairs","of","similar","sample","by","taking","same","class","samples",",","and","pairs","of","dissimilar","samples","by","taking","different","class","samples",".","It","then","passes","these","pairs","to","`","MMC","`","for","training",".","Parameters","--","--","--","--","--","max_iter",":","int",",","optional","(","default=100",")","Maximum","number","of","iterations","of","the","optimization","procedure",".","max_proj",":","int",",","optional","(","default=10000",")","Maximum","number","of","projection","steps",".","tol",":","float",",","optional","(","default=1e-3",")","Convergence","threshold","for","the","optimization","procedure",".","n_constraints",":","int",",","optional","(","default=None",")","Number","of","constraints","to","generate",".","If","None",",","default","to","`","20","*","num_classes","*","*","2","`",".","init",":","string","or","numpy","array",",","optional","(","default='identity","'",")","Initialization","of","the","Mahalanobis","matrix",".","Possible","options","are","'identity","'",",","'covariance","'",",","'random","'",",","and","a","numpy","array","of","shape","(","n_features",",","n_features",")",".","'identity'","An","identity","matrix","of","shape","(","n_features",",","n_features",")",".","'covariance'","The","(","pseudo-",")","inverse","of","the","covariance","matrix",".","'random'","The","initial","Mahalanobis","matrix","will","be","a","random","SPD","matrix","of","shape","`","(","n_features",",","n_features",")","`",",","generated","using","`","sklearn.datasets.make_spd_matrix","`",".","numpy","array","A","numpy","array","of","shape","(","n_features",",","n_features",")",",","that","will","be","used","as","such","to","initialize","the","metric",".","diagonal",":","bool",",","optional","(","default=False",")","If","True",",","a","diagonal","metric","will","be","learned",",","i.e.",",","a","simple","scaling","of","dimensions",".","The","initialization","will","then","be","the","diagonal","coefficients","of","the","matrix","given","as","'init","'",".","diagonal_c",":","float",",","optional","(","default=1.0",")","Weight","of","the","dissimilarity","constraint","for","diagonal","metric","learning",".","Ignored","if","``","diagonal=False","``",".","verbose",":","bool",",","optional","(","default=False",")","If","True",",","prints","information","while","learning","preprocessor",":","array-like",",","shape=","(","n_samples",",","n_features",")","or","callable","The","preprocessor","to","call","to","get","tuples","from","indices",".","If","array-like",",","tuples","will","be","formed","like","this",":","X","[","indices","]",".","random_state",":","int","or","numpy.RandomState","or","None",",","optional","(","default=None",")","A","pseudo","random","number","generator","object","or","a","seed","for","it","if","int",".","If","``","init='random","'","``",",","``","random_state","``","is","used","to","initialize","the","random","Mahalanobis","matrix",".","In","any","case",",","`","random_state","`","is","also","used","to","randomly","sample","constraints","from","labels",".","num_constraints",":","Renamed","to","n_constraints",".","Will","be","deprecated","in","0.7.0","convergence_threshold",":","Renamed","to","tol",".","Will","be","deprecated","in","0.7.0","Examples","--","--","--","--",">",">",">","from","metric_learn","import","MMC_Supervised",">",">",">","from","sklearn.datasets","import","load_iris",">",">",">","iris_data","=","load_iris","(",")",">",">",">","X","=","iris_data","[","'data","'","]",">",">",">","Y","=","iris_data","[","'target","'","]",">",">",">","mmc","=","MMC_Supervised","(","n_constraints=200",")",">",">",">","mmc.fit","(","X",",","Y",")","Attributes","--","--","--","--","--","n_iter_",":","`","int","`","The","number","of","iterations","the","solver","has","run",".","components_",":","`","numpy.ndarray","`",",","shape=","(","n_features",",","n_features",")","The","linear","transformation","``","L","``","deduced","from","the","learned","Mahalanobis","metric","(","See","function","`","components_from_metric","`",".",")"]
code: def __init__(
      self,
      max_iter=100,
      max_proj=10000,
      tol=1e-6,
      n_constraints=None,
      init="identity",
      diagonal=False,
      diagonal_c=1.0,
      verbose=False,
      preprocessor=None,
      random_state=None,
      num_constraints="deprecated",
      convergence_threshold="deprecated",
  ):
      _BaseMMC.__init__(
          self,
          max_iter=max_iter,
          max_proj=max_proj,
          tol=tol,
          init=init,
          diagonal=diagonal,
          diagonal_c=diagonal_c,
          verbose=verbose,
          preprocessor=preprocessor,
          random_state=random_state,
          convergence_threshold=convergence_threshold,
      )
      if num_constraints != "deprecated":
          warnings.warn(
              '"num_constraints" parameter has been renamed to'
              ' "n_constraints". It has been deprecated in'
              " version 0.6.3 and will be removed in 0.7.0"
              "",
              FutureWarning,
          )
          self.n_constraints = num_constraints
      else:
          self.n_constraints = n_constraints
      # Avoid test get_params from failing (all params passed sholud be set)
      self.num_constraints = "deprecated"
  
imports: import numpy
  from sklearn.base import TransformerMixin
  from sklearn.utils.validation import assert_all_finite
  from .base_metric import _PairsClassifierMixin, MahalanobisMixin
  from .constraints import Constraints, wrap_pairs
  from ._util import components_from_metric, _initialize_metric_mahalanobis
  import warnings
label_desc: Use image node_id 1 to create a new MMC_Supervised object from inherited base classes: _BaseMMC, TransformerMixin with example: obj = MMC_Supervised(max_iter, max_proj, tol, n_constraints, init, diagonal, diagonal_c, verbose, preprocessor, random_state, num_constraints, convergence_threshold)