class_docstr: Least Squared-residual Metric Learning (LSML)
  
  `LSML` proposes a simple, yet effective, algorithm that minimizes a convex
  objective function corresponding to the sum of squared residuals of
  constraints. This algorithm uses the constraints in the form of the
  relative distance comparisons, such method is especially useful where
  pairwise constraints are not natural to obtain, thus pairwise constraints
  based algorithms become infeasible to be deployed. Furthermore, its sparsity
  extension leads to more stable estimation when the dimension is high and
  only a small amount of constraints is given.
  
  Read more in the :ref:`User Guide <lsml>`.
  
  Parameters
  ----------
  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.
  
  tol : float, optional (default=1e-3)
    Convergence tolerance of the optimization procedure.
  
  max_iter : int, optional (default=1000)
    Maximum number of iteration of the optimization procedure.
  
  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.
  
  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`.)
  
  Examples
  --------
  >>> from metric_learn import LSML
  >>> quadruplets = [[[1.2, 7.5], [1.3, 1.5], [6.4, 2.6], [6.2, 9.7]],
  >>>                [[1.3, 4.5], [3.2, 4.6], [6.2, 5.5], [5.4, 5.4]],
  >>>                [[3.2, 7.5], [3.3, 1.5], [8.4, 2.6], [8.2, 9.7]],
  >>>                [[3.3, 4.5], [5.2, 4.6], [8.2, 5.5], [7.4, 5.4]]]
  >>> # we want to make closer points where the first feature is close, and
  >>> # further if the second feature is close
  >>> lsml = LSML()
  >>> lsml.fit(quadruplets)
  
  References
  ----------
  .. [1] Liu et al. `Metric Learning from Relative Comparisons by Minimizing
         Squared Residual
         <http://www.cs.ucla.edu/~weiwang/paper/ICDM12.pdf>`_. ICDM 2012.
  
  .. [2] Code adapted from https://gist.github.com/kcarnold/5439917
  
  See Also
  --------
  metric_learn.LSML : The original weakly-supervised algorithm
  
  :ref:`supervised_version` : The section of the project documentation
    that describes the supervised version of weakly supervised estimators.
docstr: Learn the LSML model.
  
  Parameters
  ----------
  quadruplets : array-like, shape=(n_constraints, 4, n_features) or                   (n_constraints, 4)
    3D array-like of quadruplets of points or 2D array of quadruplets of
    indicators. In order to supervise the algorithm in the right way, we
    should have the four samples ordered in a way such that:
    d(pairs[i, 0],X[i, 1]) < d(X[i, 2], X[i, 3]) for all 0 <= i <
    n_constraints.
  
  weights : (n_constraints,) array of floats, optional
    scale factor for each constraint
  
  Returns
  -------
  self : object
    Returns the instance.
docstr_tok: ["Learn","the","LSML","model",".","Parameters","--","--","--","--","--","quadruplets",":","array-like",",","shape=","(","n_constraints",",","4",",","n_features",")","or","(","n_constraints",",","4",")","3D","array-like","of","quadruplets","of","points","or","2D","array","of","quadruplets","of","indicators",".","In","order","to","supervise","the","algorithm","in","the","right","way",",","we","should","have","the","four","samples","ordered","in","a","way","such","that",":","d","(","pairs","[","i",",","0","]",",","X","[","i",",","1","]",")","<","d","(","X","[","i",",","2","]",",","X","[","i",",","3","]",")","for","all","0","<","=","i","<","n_constraints",".","weights",":","(","n_constraints",",",")","array","of","floats",",","optional","scale","factor","for","each","constraint","Returns","--","--","--","-","self",":","object","Returns","the","instance","."]
code: def fit(self, quadruplets, weights=None):
      """Learn the LSML model.
  
      Parameters
      ----------
      quadruplets : array-like, shape=(n_constraints, 4, n_features) or \
                    (n_constraints, 4)
        3D array-like of quadruplets of points or 2D array of quadruplets of
        indicators. In order to supervise the algorithm in the right way, we
        should have the four samples ordered in a way such that:
        d(pairs[i, 0],X[i, 1]) < d(X[i, 2], X[i, 3]) for all 0 <= i <
        n_constraints.
  
      weights : (n_constraints,) array of floats, optional
        scale factor for each constraint
  
      Returns
      -------
      self : object
        Returns the instance.
      """
      return self._fit(quadruplets, weights=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 1 for calling the LSML obj's underlying member method code with example usage: obj.fit(quadruplets, weights) and returns: self