class_docstr: Sparse Distance Metric Learning (SDML)
  
  SDML is an efficient sparse metric learning in high-dimensional space via
  double regularization: an L1-penalization on the off-diagonal elements of the
  Mahalanobis matrix :math:`\mathbf{M}`, and a log-determinant divergence
  between :math:`\mathbf{M}` and :math:`\mathbf{M_0}` (set as either
  :math:`\mathbf{I}` or :math:`\mathbf{\Omega}^{-1}`, where
  :math:`\mathbf{\Omega}` is the covariance matrix).
  
  Read more in the :ref:`User Guide <sdml>`.
  
  Parameters
  ----------
  balance_param : float, optional (default=0.5)
    Trade off between sparsity and M0 prior.
  
  sparsity_param : float, optional  (default=0.01)
    Trade off between optimizer and sparseness (see graph_lasso).
  
  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 SDML, 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 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.
  
  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 gotten 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.
  
  Attributes
  ----------
  components_ : `numpy.ndarray`, shape=(n_features, n_features)
    The linear transformation ``L`` deduced from the learned Mahalanobis
    metric (See function `components_from_metric`.)
  
  threshold_ : `float`
    If the distance metric between two points is lower than this threshold,
    points will be classified as similar, otherwise they will be
    classified as dissimilar.
  
  Examples
  --------
  >>> from metric_learn import SDML_Supervised
  >>> from sklearn.datasets import load_iris
  >>> iris_data = load_iris()
  >>> X = iris_data['data']
  >>> Y = iris_data['target']
  >>> sdml = SDML_Supervised(n_constraints=200)
  >>> sdml.fit(X, Y)
  
  References
  ----------
  .. [1] Qi et al. `An efficient sparse metric learning in high-dimensional
         space via L1-penalized log-determinant regularization
         <http://www.machinelearning.org/archive/icml2009/papers/46.pdf>`_.
         ICML 2009.
  
  .. [2] Code adapted from https://gist.github.com/kcarnold/5439945
class_docstr_tok: ["Sparse","Distance","Metric","Learning","(","SDML",")","SDML","is","an","efficient","sparse","metric","learning","in","high-dimensional","space","via","double","regularization",":","an","L1-penalization","on","the","off-diagonal","elements","of","the","Mahalanobis","matrix",":","math",":","`","\\mathbf","{","M","}","`",",","and","a","log-determinant","divergence","between",":","math",":","`","\\mathbf","{","M","}","`","and",":","math",":","`","\\mathbf","{","M_0","}","`","(","set","as","either",":","math",":","`","\\mathbf","{","I","}","`","or",":","math",":","`","\\mathbf","{","\\Omega","}","^","{","-1","}","`",",","where",":","math",":","`","\\mathbf","{","\\Omega","}","`","is","the","covariance","matrix",")",".","Read","more","in","the",":","ref",":","`","User","Guide","<","sdml",">","`",".","Parameters","--","--","--","--","--","balance_param",":","float",",","optional","(","default=0.5",")","Trade","off","between","sparsity","and","M0","prior",".","sparsity_param",":","float",",","optional","(","default=0.01",")","Trade","off","between","optimizer","and","sparseness","(","see","graph_lasso",")",".","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","SDML",",","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","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",".","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","gotten","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",".","Attributes","--","--","--","--","--","components_",":","`","numpy.ndarray","`",",","shape=","(","n_features",",","n_features",")","The","linear","transformation","``","L","``","deduced","from","the","learned","Mahalanobis","metric","(","See","function","`","components_from_metric","`",".",")","threshold_",":","`","float","`","If","the","distance","metric","between","two","points","is","lower","than","this","threshold",",","points","will","be","classified","as","similar",",","otherwise","they","will","be","classified","as","dissimilar",".","Examples","--","--","--","--",">",">",">","from","metric_learn","import","SDML_Supervised",">",">",">","from","sklearn.datasets","import","load_iris",">",">",">","iris_data","=","load_iris","(",")",">",">",">","X","=","iris_data","[","'data","'","]",">",">",">","Y","=","iris_data","[","'target","'","]",">",">",">","sdml","=","SDML_Supervised","(","n_constraints=200",")",">",">",">","sdml.fit","(","X",",","Y",")","References","--","--","--","--","--","..","[","1","]","Qi","et","al",".","`","An","efficient","sparse","metric","learning","in","high-dimensional","space","via","L1-penalized","log-determinant","regularization","<","http",":","\/\/www.machinelearning.org\/archive\/icml2009\/papers\/46.pdf",">","`","_",".","ICML","2009",".","..","[","2","]","Code","adapted","from","https",":","\/\/gist.github.com\/kcarnold\/5439945"]
docstr: Learn the SDML model.
  
  The threshold will be calibrated on the trainset using the parameters
  `calibration_params`.
  
  Parameters
  ----------
  pairs : array-like, shape=(n_constraints, 2, n_features) or            (n_constraints, 2)
    3D Array of pairs with each row corresponding to two points,
    or 2D array of indices of pairs if the metric learner uses a
    preprocessor.
  
  y : array-like, of shape (n_constraints,)
    Labels of constraints. Should be -1 for dissimilar pair, 1 for similar.
  
  calibration_params : `dict` or `None`
    Dictionary of parameters to give to `calibrate_threshold` for the
    threshold calibration step done at the end of `fit`. If `None` is
    given, `calibrate_threshold` will use the default parameters.
  
  Returns
  -------
  self : object
    Returns the instance.
docstr_tok: ["Learn","the","SDML","model",".","The","threshold","will","be","calibrated","on","the","trainset","using","the","parameters","`","calibration_params","`",".","Parameters","--","--","--","--","--","pairs",":","array-like",",","shape=","(","n_constraints",",","2",",","n_features",")","or","(","n_constraints",",","2",")","3D","Array","of","pairs","with","each","row","corresponding","to","two","points",",","or","2D","array","of","indices","of","pairs","if","the","metric","learner","uses","a","preprocessor",".","y",":","array-like",",","of","shape","(","n_constraints",",",")","Labels","of","constraints",".","Should","be","-1","for","dissimilar","pair",",","1","for","similar",".","calibration_params",":","`","dict","`","or","`","None","`","Dictionary","of","parameters","to","give","to","`","calibrate_threshold","`","for","the","threshold","calibration","step","done","at","the","end","of","`","fit","`",".","If","`","None","`","is","given",",","`","calibrate_threshold","`","will","use","the","default","parameters",".","Returns","--","--","--","-","self",":","object","Returns","the","instance","."]
code: def fit(self, pairs, y, calibration_params=None):
      """Learn the SDML model.
  
      The threshold will be calibrated on the trainset using the parameters
      `calibration_params`.
  
      Parameters
      ----------
      pairs : array-like, shape=(n_constraints, 2, n_features) or \
             (n_constraints, 2)
        3D Array of pairs with each row corresponding to two points,
        or 2D array of indices of pairs if the metric learner uses a
        preprocessor.
  
      y : array-like, of shape (n_constraints,)
        Labels of constraints. Should be -1 for dissimilar pair, 1 for similar.
  
      calibration_params : `dict` or `None`
        Dictionary of parameters to give to `calibrate_threshold` for the
        threshold calibration step done at the end of `fit`. If `None` is
        given, `calibrate_threshold` will use the default parameters.
  
      Returns
      -------
      self : object
        Returns the instance.
      """
      calibration_params = (
          calibration_params
          if calibration_params is not None
          else dict()
      )
      self._validate_calibration_params(**calibration_params)
      self._fit(pairs, y)
      self.calibrate_threshold(pairs, y, **calibration_params)
      return self
  
imports: import warnings
  import numpy
  from sklearn.base import TransformerMixin
  from scipy.linalg import pinvh
  from sklearn.covariance import graphical_lasso
  from sklearn.exceptions import ConvergenceWarning
  from .base_metric import MahalanobisMixin, _PairsClassifierMixin
  from .constraints import Constraints, wrap_pairs
  from ._util import components_from_metric, _initialize_metric_mahalanobis
label_desc: Use image node_id 1 for calling the SDML obj's underlying member method code with example usage: obj.fit(pairs, y, calibration_params) and returns: self