class_docstr: Supervised version of Information Theoretic Metric Learning (ITML)
  
  `ITML_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 `ITML` for training.
  
  Parameters
  ----------
  gamma : float, optional (default=1.0)
    Value for slack variables
  
  max_iter : int, optional (default=1000)
    Maximum number of iterations of the optimization procedure.
  
  tol : float, optional (default=1e-3)
    Tolerance of the optimization procedure.
  
  n_constraints : int, optional (default=None)
    Number of constraints to generate. If None, default to `20 *
    num_classes**2`.
  
  prior : 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). For ITML, the prior should be strictly
    positive definite (PD).
  
    'identity'
      An identity matrix of shape (n_features, n_features).
  
    'covariance'
      The inverse covariance matrix.
  
    'random'
      The prior will be a random SPD matrix of shape
      `(n_features, n_features)`, generated using
      `sklearn.datasets.make_spd_matrix`.
  
    numpy array
      A positive definite (PD) matrix of shape
      (n_features, n_features), that will be used as such to set the
      prior.
  
  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
    ``prior='random'``, ``random_state`` is used to set the prior. 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
  
  Attributes
  ----------
  bounds_ : `numpy.ndarray`, shape=(2,)
    Bounds on similarity, aside slack variables, s.t.
    ``d(a, b) < bounds_[0]`` for all given pairs of similar points ``a``
    and ``b``, and ``d(c, d) > bounds_[1]`` for all given pairs of
    dissimilar points ``c`` and ``d``, with ``d`` the learned distance.
    If not provided at initialization, bounds_[0] and bounds_[1] are set at
    train time to the 5th and 95th percentile of the pairwise distances
    among all points in the training data `X`.
  
  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`.)
  
  Examples
  --------
  >>> from metric_learn import ITML_Supervised
  >>> from sklearn.datasets import load_iris
  >>> iris_data = load_iris()
  >>> X = iris_data['data']
  >>> Y = iris_data['target']
  >>> itml = ITML_Supervised(n_constraints=200)
  >>> itml.fit(X, Y)
  
  See Also
  --------
  metric_learn.ITML : The original weakly-supervised algorithm
  :ref:`supervised_version` : The section of the project documentation
    that describes the supervised version of weakly supervised estimators.
class_docstr_tok: ["Supervised","version","of","Information","Theoretic","Metric","Learning","(","ITML",")","`","ITML_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","`","ITML","`","for","training",".","Parameters","--","--","--","--","--","gamma",":","float",",","optional","(","default=1.0",")","Value","for","slack","variables","max_iter",":","int",",","optional","(","default=1000",")","Maximum","number","of","iterations","of","the","optimization","procedure",".","tol",":","float",",","optional","(","default=1e-3",")","Tolerance","of","the","optimization","procedure",".","n_constraints",":","int",",","optional","(","default=None",")","Number","of","constraints","to","generate",".","If","None",",","default","to","`","20","*","num_classes","*","*","2","`",".","prior",":","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",")",".","For","ITML",",","the","prior","should","be","strictly","positive","definite","(","PD",")",".","'identity'","An","identity","matrix","of","shape","(","n_features",",","n_features",")",".","'covariance'","The","inverse","covariance","matrix",".","'random'","The","prior","will","be","a","random","SPD","matrix","of","shape","`","(","n_features",",","n_features",")","`",",","generated","using","`","sklearn.datasets.make_spd_matrix","`",".","numpy","array","A","positive","definite","(","PD",")","matrix","of","shape","(","n_features",",","n_features",")",",","that","will","be","used","as","such","to","set","the","prior",".","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","``","prior='random","'","``",",","``","random_state","``","is","used","to","set","the","prior",".","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","Attributes","--","--","--","--","--","bounds_",":","`","numpy.ndarray","`",",","shape=","(","2",",",")","Bounds","on","similarity",",","aside","slack","variables",",","s.t",".","``","d","(","a",",","b",")","<","bounds_","[","0","]","``","for","all","given","pairs","of","similar","points","``","a","``","and","``","b","``",",","and","``","d","(","c",",","d",")",">","bounds_","[","1","]","``","for","all","given","pairs","of","dissimilar","points","``","c","``","and","``","d","``",",","with","``","d","``","the","learned","distance",".","If","not","provided","at","initialization",",","bounds_","[","0","]","and","bounds_","[","1","]","are","set","at","train","time","to","the","5th","and","95th","percentile","of","the","pairwise","distances","among","all","points","in","the","training","data","`","X","`",".","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","`",".",")","Examples","--","--","--","--",">",">",">","from","metric_learn","import","ITML_Supervised",">",">",">","from","sklearn.datasets","import","load_iris",">",">",">","iris_data","=","load_iris","(",")",">",">",">","X","=","iris_data","[","'data","'","]",">",">",">","Y","=","iris_data","[","'target","'","]",">",">",">","itml","=","ITML_Supervised","(","n_constraints=200",")",">",">",">","itml.fit","(","X",",","Y",")","See","Also","--","--","--","--","metric_learn.ITML",":","The","original","weakly-supervised","algorithm",":","ref",":","`","supervised_version","`",":","The","section","of","the","project","documentation","that","describes","the","supervised","version","of","weakly","supervised","estimators","."]
docstr: Create constraints from labels and learn the ITML model.
  
  
  Parameters
  ----------
  X : (n x d) matrix
    Input data, where each row corresponds to a single instance.
  
  y : (n) array-like
    Data labels.
  
  bounds : array-like of two numbers
    Bounds on similarity, aside slack variables, s.t.
    ``d(a, b) < bounds_[0]`` for all given pairs of similar points ``a``
    and ``b``, and ``d(c, d) > bounds_[1]`` for all given pairs of
    dissimilar points ``c`` and ``d``, with ``d`` the learned distance.
    If not provided at initialization, bounds_[0] and bounds_[1] will be
    set to the 5th and 95th percentile of the pairwise distances among all
    points in the training data `X`.
docstr_tok: ["Create","constraints","from","labels","and","learn","the","ITML","model",".","Parameters","--","--","--","--","--","X",":","(","n","x","d",")","matrix","Input","data",",","where","each","row","corresponds","to","a","single","instance",".","y",":","(","n",")","array-like","Data","labels",".","bounds",":","array-like","of","two","numbers","Bounds","on","similarity",",","aside","slack","variables",",","s.t",".","``","d","(","a",",","b",")","<","bounds_","[","0","]","``","for","all","given","pairs","of","similar","points","``","a","``","and","``","b","``",",","and","``","d","(","c",",","d",")",">","bounds_","[","1","]","``","for","all","given","pairs","of","dissimilar","points","``","c","``","and","``","d","``",",","with","``","d","``","the","learned","distance",".","If","not","provided","at","initialization",",","bounds_","[","0","]","and","bounds_","[","1","]","will","be","set","to","the","5th","and","95th","percentile","of","the","pairwise","distances","among","all","points","in","the","training","data","`","X","`","."]
code: def fit(self, X, y, bounds=None):
      """Create constraints from labels and learn the ITML model.
  
  
      Parameters
      ----------
      X : (n x d) matrix
        Input data, where each row corresponds to a single instance.
  
      y : (n) array-like
        Data labels.
  
      bounds : array-like of two numbers
        Bounds on similarity, aside slack variables, s.t.
        ``d(a, b) < bounds_[0]`` for all given pairs of similar points ``a``
        and ``b``, and ``d(c, d) > bounds_[1]`` for all given pairs of
        dissimilar points ``c`` and ``d``, with ``d`` the learned distance.
        If not provided at initialization, bounds_[0] and bounds_[1] will be
        set to the 5th and 95th percentile of the pairwise distances among all
        points in the training data `X`.
      """
      X, y = self._prepare_inputs(X, y, ensure_min_samples=2)
      n_constraints = self.n_constraints
      if n_constraints is None:
          num_classes = len(np.unique(y))
          n_constraints = 20 * num_classes**2
  
      c = Constraints(y)
      pos_neg = c.positive_negative_pairs(
          n_constraints, random_state=self.random_state
      )
      pairs, y = wrap_pairs(X, pos_neg)
      return _BaseITML._fit(self, pairs, y, bounds=bounds)
  
imports: import numpy
  from sklearn.metrics import pairwise_distances
  from sklearn.utils.validation import check_array
  from sklearn.base import TransformerMixin
  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 2 for calling the ITML_Supervised obj's underlying member method code with example usage: obj.fit(X, y, bounds) and returns: _BaseITML