class_docstr: Supervised version of Least Squared-residual Metric Learning (LSML)
  
  `LSML_Supervised` creates quadruplets from labeled samples by taking two
  samples from the same class, and two samples from different classes.
  This way it builds quadruplets where the two first points must be more
  similar than the two last points.
  
  Parameters
  ----------
  tol : float, optional (default=1e-3)
    Convergence tolerance of the optimization procedure.
  
  max_iter : int, optional (default=1000)
    Number of maximum iterations of the optimization procedure.
  
  prior : string or numpy array, optional (default='identity')
    Prior to set for the metric. Possible options are
    'identity', 'covariance', 'random', and a numpy array of
    shape (n_features, n_features). For LSML, 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 initial Mahalanobis matrix will be a random positive definite
      (PD) 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.
  
  n_constraints: int, optional (default=None)
    Number of constraints to generate. If None, default to `20 *
    num_classes**2`.
  
  weights : (n_constraints,) array of floats, optional (default=None)
    Relative weight given to each constraint. If None, defaults to uniform
    weights.
  
  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 set the random
    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
  
  Examples
  --------
  >>> from metric_learn import LSML_Supervised
  >>> from sklearn.datasets import load_iris
  >>> iris_data = load_iris()
  >>> X = iris_data['data']
  >>> Y = iris_data['target']
  >>> lsml = LSML_Supervised(n_constraints=200)
  >>> lsml.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`.)
docstr: Create constraints from labels and learn the LSML model.
  
  Parameters
  ----------
  X : (n x d) matrix
    Input data, where each row corresponds to a single instance.
  
  y : (n) array-like
    Data labels.
docstr_tok: ["Create","constraints","from","labels","and","learn","the","LSML","model",".","Parameters","--","--","--","--","--","X",":","(","n","x","d",")","matrix","Input","data",",","where","each","row","corresponds","to","a","single","instance",".","y",":","(","n",")","array-like","Data","labels","."]
code: def fit(self, X, y):
      """Create constraints from labels and learn the LSML model.
  
      Parameters
      ----------
      X : (n x d) matrix
        Input data, where each row corresponds to a single instance.
  
      y : (n) array-like
        Data labels.
      """
      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,
          same_length=True,
          random_state=self.random_state,
      )
      return _BaseLSML._fit(
          self, X[np.column_stack(pos_neg)], weights=self.weights
      )
  
imports: import numpy
  import scipy.linalg
  from sklearn.base import TransformerMixin
  from .base_metric import _QuadrupletsClassifierMixin, MahalanobisMixin
  from .constraints import Constraints
  from ._util import components_from_metric, _initialize_metric_mahalanobis
  import warnings
label_desc: Use image node_id 2 for calling the LSML_Supervised obj's underlying member method code with example usage: obj.fit(X, y) and returns: _BaseLSML