class_docstr: Supervised version of Sparse Compositional Metric Learning (SCML)
  
  `SCML_Supervised` creates triplets by taking `k_genuine` neighbours
  of the same class and `k_impostor` neighbours from different classes for each
  point and then runs the SCML algorithm on these triplets.
  
  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 an array-like, optional (default='lda')
    Set of bases to construct the metric. Possible options are
    'lda', and an array-like of shape (n_basis, n_features).
  
    'lda'
      The `n_basis` basis set is constructed from the LDA of significant
      local regions in the feature space via clustering, for each region
      center k-nearest neighbors are used to obtain the LDA scalings,
      which correspond to the locally discriminative basis.
  
    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 = 100000)
    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_Supervised
  >>> from sklearn.datasets import load_iris
  >>> iris_data = load_iris()
  >>> X = iris_data['data']
  >>> Y = iris_data['target']
  >>> scml = SCML_Supervised(random_state=33)
  >>> scml.fit(X, Y)
  SCML_Supervised(random_state=33)
  >>> scml.score_pairs([[X[0], X[1]], [X[0], X[2]]])
  array([1.84640733, 1.55984363])
  >>> scml.get_metric()(X[0], X[1])
  1.8464073327922157
  
  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 : The weakly supervised version of this
    algorithm.
class_docstr_tok: ["Supervised","version","of","Sparse","Compositional","Metric","Learning","(","SCML",")","`","SCML_Supervised","`","creates","triplets","by","taking","`","k_genuine","`","neighbours","of","the","same","class","and","`","k_impostor","`","neighbours","from","different","classes","for","each","point","and","then","runs","the","SCML","algorithm","on","these","triplets",".","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","an","array-like",",","optional","(","default='lda","'",")","Set","of","bases","to","construct","the","metric",".","Possible","options","are","'lda","'",",","and","an","array-like","of","shape","(","n_basis",",","n_features",")",".","'lda'","The","`","n_basis","`","basis","set","is","constructed","from","the","LDA","of","significant","local","regions","in","the","feature","space","via","clustering",",","for","each","region","center","k-nearest","neighbors","are","used","to","obtain","the","LDA","scalings",",","which","correspond","to","the","locally","discriminative","basis",".","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","=","100000",")","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_Supervised",">",">",">","from","sklearn.datasets","import","load_iris",">",">",">","iris_data","=","load_iris","(",")",">",">",">","X","=","iris_data","[","'data","'","]",">",">",">","Y","=","iris_data","[","'target","'","]",">",">",">","scml","=","SCML_Supervised","(","random_state=33",")",">",">",">","scml.fit","(","X",",","Y",")","SCML_Supervised","(","random_state=33",")",">",">",">","scml.score_pairs","(","[","[","X","[","0","]",",","X","[","1","]","]",",","[","X","[","0","]",",","X","[","2","]","]","]",")","array","(","[","1.84640733",",","1.55984363","]",")",">",">",">","scml.get_metric","(",")","(","X","[","0","]",",","X","[","1","]",")","1.8464073327922157","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",":","The","weakly","supervised","version","of","this","algorithm","."]
docstr: Constructs the basis set following one of the supervised options in
  case one is selected.
docstr_tok: ["Constructs","the","basis","set","following","one","of","the","supervised","options","in","case","one","is","selected","."]
code: def _initialize_basis_supervised(self, X, y):
      """Constructs the basis set following one of the supervised options in
      case one is selected.
      """
  
      if isinstance(self.basis, str) and self.basis == "lda":
          basis, n_basis = self._generate_bases_LDA(X, y)
      else:
          basis, n_basis = None, None
  
      return basis, n_basis
  
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 3 for calling the SCML_Supervised obj's underlying member method code with example usage: obj._initialize_basis_supervised(X, y) and returns: basis,  n_basis