class_docstr: Supervised version of Sparse Distance Metric Learning (SDML)
  
  `SDML_Supervised` creates pairs of similar sample by taking same class
  samples, and pairs of dissimilar samples by taking different class
  samples. It then passes these pairs to `SDML` for training.
  
  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 SPD 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, defaults to `20 *
    num_classes**2`.
  
  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
  
  Attributes
  ----------
  components_ : `numpy.ndarray`, shape=(n_features, n_features)
    The linear transformation ``L`` deduced from the learned Mahalanobis
    metric (See function `components_from_metric`.)
  
  See Also
  --------
  metric_learn.SDML : The original weakly-supervised algorithm
  :ref:`supervised_version` : The section of the project documentation
    that describes the supervised version of weakly supervised estimators.
class_docstr_tok: ["Supervised","version","of","Sparse","Distance","Metric","Learning","(","SDML",")","`","SDML_Supervised","`","creates","pairs","of","similar","sample","by","taking","same","class","samples",",","and","pairs","of","dissimilar","samples","by","taking","different","class","samples",".","It","then","passes","these","pairs","to","`","SDML","`","for","training",".","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","SPD","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",",","defaults","to","`","20","*","num_classes","*","*","2","`",".","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","Attributes","--","--","--","--","--","components_",":","`","numpy.ndarray","`",",","shape=","(","n_features",",","n_features",")","The","linear","transformation","``","L","``","deduced","from","the","learned","Mahalanobis","metric","(","See","function","`","components_from_metric","`",".",")","See","Also","--","--","--","--","metric_learn.SDML",":","The","original","weakly-supervised","algorithm",":","ref",":","`","supervised_version","`",":","The","section","of","the","project","documentation","that","describes","the","supervised","version","of","weakly","supervised","estimators","."]
code: def __init__(
      self,
      balance_param=0.5,
      sparsity_param=0.01,
      prior="identity",
      n_constraints=None,
      verbose=False,
      preprocessor=None,
      random_state=None,
      num_constraints="deprecated",
  ):
      _BaseSDML.__init__(
          self,
          balance_param=balance_param,
          sparsity_param=sparsity_param,
          prior=prior,
          verbose=verbose,
          preprocessor=preprocessor,
          random_state=random_state,
      )
      if num_constraints != "deprecated":
          warnings.warn(
              '"num_constraints" parameter has been renamed to'
              ' "n_constraints". It has been deprecated in'
              " version 0.6.3 and will be removed in 0.7.0"
              "",
              FutureWarning,
          )
          self.n_constraints = num_constraints
      else:
          self.n_constraints = n_constraints
      # Avoid test get_params from failing (all params passed sholud be set)
      self.num_constraints = "deprecated"
  
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 to create a new SDML_Supervised object from inherited base classes: _BaseSDML, TransformerMixin with example: obj = SDML_Supervised(balance_param, sparsity_param, prior, n_constraints, verbose, preprocessor, random_state, num_constraints)