class_docstr: Sparse Compositional Metric Learning (SCML)
  
  `SCML` learns an squared Mahalanobis distance from triplet constraints by
  optimizing sparse positive weights assigned to a set of :math:`K` rank-one
  PSD bases. This can be formulated as an optimization problem with only
  :math:`K` parameters, that can be solved with an efficient stochastic
  composite scheme.
  
  Read more in the :ref:`User Guide <scml>`.
  
  .. warning::
    SCML is still a bit experimental, don't hesitate to report if
    something fails/doesn't work as expected.
  
  Parameters
  ----------
  beta: float (default=1e-5)
    L1 regularization parameter.
  
  basis : string or array-like, optional (default='triplet_diffs')
    Set of bases to construct the metric. Possible options are
    'triplet_diffs', and an array-like of shape (n_basis, n_features).
  
    'triplet_diffs'
      The basis set is constructed iteratively from differences between points
      of `n_features` positive or negative pairs randomly sampled from the
      triplets constraints. Requires the number of training triplets to be
      great or equal to `n_features`.
  
    array-like
        A matrix of shape (n_basis, n_features), that will be used as
        the basis set for the metric construction.
  
  n_basis : int, optional
    Number of basis to be yielded. In case it is not set it will be set based
    on `basis`. If no value is selected a default will be computed based on
    the input.
  
  gamma: float (default = 5e-3)
    Learning rate for the optimization algorithm.
  
  max_iter : int (default = 10000)
    Number of iterations for the algorithm.
  
  output_iter : int (default = 5000)
    Number of iterations to check current weights performance and output this
    information in case verbose is True.
  
  verbose : bool, optional
    If True, prints information while learning.
  
  preprocessor : array-like, shape=(n_samples, n_features) or callable
    The preprocessor to call to get triplets from indices. If array-like,
    triplets 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.
  
  Attributes
  ----------
  components_ : `numpy.ndarray`, shape=(n_features, n_features)
    The linear transformation ``L`` deduced from the learned Mahalanobis
    metric (See function `_components_from_basis_weights`.)
  
  Examples
  --------
  >>> from metric_learn import SCML
  >>> triplets = [[[1.2, 7.5], [1.3, 1.5], [6.2, 9.7]],
  >>>             [[1.3, 4.5], [3.2, 4.6], [5.4, 5.4]],
  >>>             [[3.2, 7.5], [3.3, 1.5], [8.2, 9.7]],
  >>>             [[3.3, 4.5], [5.2, 4.6], [7.4, 5.4]]]
  >>> scml = SCML()
  >>> scml.fit(triplets)
  
  References
  ----------
  .. [1] Y. Shi, A. Bellet and F. Sha. `Sparse Compositional Metric Learning.
         <http://researchers.lille.inria.fr/abellet/papers/aaai14.pdf>`_.          (AAAI), 2014.
  
  .. [2] Adapted from original `Matlab implementation.          <https://github.com/bellet/SCML>`_.
  
  See Also
  --------
  metric_learn.SCML_Supervised : The supervised version of the algorithm.
  
  :ref:`supervised_version` : The section of the project documentation
    that describes the supervised version of weakly supervised estimators.
class_docstr_tok: ["Sparse","Compositional","Metric","Learning","(","SCML",")","`","SCML","`","learns","an","squared","Mahalanobis","distance","from","triplet","constraints","by","optimizing","sparse","positive","weights","assigned","to","a","set","of",":","math",":","`","K","`","rank-one","PSD","bases",".","This","can","be","formulated","as","an","optimization","problem","with","only",":","math",":","`","K","`","parameters",",","that","can","be","solved","with","an","efficient","stochastic","composite","scheme",".","Read","more","in","the",":","ref",":","`","User","Guide","<","scml",">","`",".","..","warning",":",":","SCML","is","still","a","bit","experimental",",","do","n't","hesitate","to","report","if","something","fails\/does","n't","work","as","expected",".","Parameters","--","--","--","--","--","beta",":","float","(","default=1e-5",")","L1","regularization","parameter",".","basis",":","string","or","array-like",",","optional","(","default='triplet_diffs","'",")","Set","of","bases","to","construct","the","metric",".","Possible","options","are","'triplet_diffs","'",",","and","an","array-like","of","shape","(","n_basis",",","n_features",")",".","'triplet_diffs'","The","basis","set","is","constructed","iteratively","from","differences","between","points","of","`","n_features","`","positive","or","negative","pairs","randomly","sampled","from","the","triplets","constraints",".","Requires","the","number","of","training","triplets","to","be","great","or","equal","to","`","n_features","`",".","array-like","A","matrix","of","shape","(","n_basis",",","n_features",")",",","that","will","be","used","as","the","basis","set","for","the","metric","construction",".","n_basis",":","int",",","optional","Number","of","basis","to","be","yielded",".","In","case","it","is","not","set","it","will","be","set","based","on","`","basis","`",".","If","no","value","is","selected","a","default","will","be","computed","based","on","the","input",".","gamma",":","float","(","default","=","5e-3",")","Learning","rate","for","the","optimization","algorithm",".","max_iter",":","int","(","default","=","10000",")","Number","of","iterations","for","the","algorithm",".","output_iter",":","int","(","default","=","5000",")","Number","of","iterations","to","check","current","weights","performance","and","output","this","information","in","case","verbose","is","True",".","verbose",":","bool",",","optional","If","True",",","prints","information","while","learning",".","preprocessor",":","array-like",",","shape=","(","n_samples",",","n_features",")","or","callable","The","preprocessor","to","call","to","get","triplets","from","indices",".","If","array-like",",","triplets","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",".","Attributes","--","--","--","--","--","components_",":","`","numpy.ndarray","`",",","shape=","(","n_features",",","n_features",")","The","linear","transformation","``","L","``","deduced","from","the","learned","Mahalanobis","metric","(","See","function","`","_components_from_basis_weights","`",".",")","Examples","--","--","--","--",">",">",">","from","metric_learn","import","SCML",">",">",">","triplets","=","[","[","[","1.2",",","7.5","]",",","[","1.3",",","1.5","]",",","[","6.2",",","9.7","]","]",",",">",">",">","[","[","1.3",",","4.5","]",",","[","3.2",",","4.6","]",",","[","5.4",",","5.4","]","]",",",">",">",">","[","[","3.2",",","7.5","]",",","[","3.3",",","1.5","]",",","[","8.2",",","9.7","]","]",",",">",">",">","[","[","3.3",",","4.5","]",",","[","5.2",",","4.6","]",",","[","7.4",",","5.4","]","]","]",">",">",">","scml","=","SCML","(",")",">",">",">","scml.fit","(","triplets",")","References","--","--","--","--","--","..","[","1","]","Y.","Shi",",","A.","Bellet","and","F.","Sha",".","`","Sparse","Compositional","Metric","Learning",".","<","http",":","\/\/researchers.lille.inria.fr\/abellet\/papers\/aaai14.pdf",">","`","_",".","(","AAAI",")",",","2014",".","..","[","2","]","Adapted","from","original","`","Matlab","implementation",".","<","https",":","\/\/github.com\/bellet\/SCML",">","`","_",".","See","Also","--","--","--","--","metric_learn.SCML_Supervised",":","The","supervised","version","of","the","algorithm",".",":","ref",":","`","supervised_version","`",":","The","section","of","the","project","documentation","that","describes","the","supervised","version","of","weakly","supervised","estimators","."]
docstr: Learn the SCML model.
  
  Parameters
  ----------
  triplets : array-like, shape=(n_constraints, 3, n_features) or       (n_constraints, 3)
    3D array-like of triplets of points or 2D array of triplets of
    indicators. Triplets are assumed to be ordered such that:
    d(triplets[i, 0],triplets[i, 1]) < d(triplets[i, 0], triplets[i, 2]).
  
  Returns
  -------
  self : object
    Returns the instance.
docstr_tok: ["Learn","the","SCML","model",".","Parameters","--","--","--","--","--","triplets",":","array-like",",","shape=","(","n_constraints",",","3",",","n_features",")","or","(","n_constraints",",","3",")","3D","array-like","of","triplets","of","points","or","2D","array","of","triplets","of","indicators",".","Triplets","are","assumed","to","be","ordered","such","that",":","d","(","triplets","[","i",",","0","]",",","triplets","[","i",",","1","]",")","<","d","(","triplets","[","i",",","0","]",",","triplets","[","i",",","2","]",")",".","Returns","--","--","--","-","self",":","object","Returns","the","instance","."]
code: def fit(self, triplets):
      """Learn the SCML model.
  
      Parameters
      ----------
      triplets : array-like, shape=(n_constraints, 3, n_features) or \
        (n_constraints, 3)
        3D array-like of triplets of points or 2D array of triplets of
        indicators. Triplets are assumed to be ordered such that:
        d(triplets[i, 0],triplets[i, 1]) < d(triplets[i, 0], triplets[i, 2]).
  
      Returns
      -------
      self : object
        Returns the instance.
      """
  
      return self._fit(triplets)
  
imports: from __future__ import print_function, absolute_import, division
  import numpy
  from .base_metric import _TripletsClassifierMixin, MahalanobisMixin
  from ._util import components_from_metric
  from sklearn.base import TransformerMixin
  from .constraints import Constraints
  from sklearn.preprocessing import normalize
  from sklearn.neighbors import NearestNeighbors
  from sklearn.cluster import KMeans
  from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
  from sklearn.utils import check_array, check_random_state
  import warnings
label_desc: Use image node_id 1 for calling the SCML obj's underlying member method code with example usage: obj.fit(triplets) and returns: self