class_docstr: Mahalanobis metric learning algorithms.
  
  Algorithm that learns a Mahalanobis (pseudo) distance :math:`d_M(x, x')`,
  defined between two column vectors :math:`x` and :math:`x'` by: :math:`d_M(x,
  x') = \sqrt{(x-x')^T M (x-x')}`, where :math:`M` is a learned symmetric
  positive semi-definite (PSD) matrix. The metric between points can then be
  expressed as the euclidean distance between points embedded in a new space
  through a linear transformation. Indeed, the above matrix can be decomposed
  into the product of two transpose matrices (through SVD or Cholesky
  decomposition): :math:`d_M(x, x')^2 = (x-x')^T M (x-x') = (x-x')^T L^T L
  (x-x') = (L x - L x')^T (L x- L x')`
  
  Attributes
  ----------
  components_ : `numpy.ndarray`, shape=(n_components, n_features)
    The learned linear transformation ``L``.
class_docstr_tok: ["Mahalanobis","metric","learning","algorithms",".","Algorithm","that","learns","a","Mahalanobis","(","pseudo",")","distance",":","math",":","`","d_M","(","x",",","x","'",")","`",",","defined","between","two","column","vectors",":","math",":","`","x","`","and",":","math",":","`","x","'","`","by",":",":","math",":","`","d_M","(","x",",","x","'",")","=","\\sqrt","{","(","x-x","'",")","^T","M","(","x-x","'",")","}","`",",","where",":","math",":","`","M","`","is","a","learned","symmetric","positive","semi-definite","(","PSD",")","matrix",".","The","metric","between","points","can","then","be","expressed","as","the","euclidean","distance","between","points","embedded","in","a","new","space","through","a","linear","transformation",".","Indeed",",","the","above","matrix","can","be","decomposed","into","the","product","of","two","transpose","matrices","(","through","SVD","or","Cholesky","decomposition",")",":",":","math",":","`","d_M","(","x",",","x","'",")","^2","=","(","x-x","'",")","^T","M","(","x-x","'",")","=","(","x-x","'",")","^T","L^T","L","(","x-x","'",")","=","(","L","x","-","L","x","'",")","^T","(","L","x-","L","x","'",")","`","Attributes","--","--","--","--","--","components_",":","`","numpy.ndarray","`",",","shape=","(","n_components",",","n_features",")","The","learned","linear","transformation","``","L","``","."]
code: def get_metric(self):
      check_is_fitted(self, "components_")
      components_T = self.components_.T.copy()
  
      def metric_fun(u, v, squared=False):
          """This function computes the metric between u and v, according to the
          previously learned metric.
  
          Parameters
          ----------
          u : array-like, shape=(n_features,)
            The first point involved in the distance computation.
  
          v : array-like, shape=(n_features,)
            The second point involved in the distance computation.
  
          squared : `bool`
            If True, the function will return the squared metric between u and
            v, which is faster to compute.
  
          Returns
          -------
          distance : float
            The distance between u and v according to the new metric.
          """
          u = validate_vector(u)
          v = validate_vector(v)
          transformed_diff = (u - v).dot(components_T)
          dist = np.dot(transformed_diff, transformed_diff.T)
          if not squared:
              dist = np.sqrt(dist)
          return dist
  
      return metric_fun
  
imports: from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.utils.extmath import stable_cumsum
  from sklearn.utils.validation import _is_arraylike, check_is_fitted
  from sklearn.metrics import roc_auc_score, roc_curve, precision_recall_curve
  import numpy
  from abc import ABCMeta, abstractmethod
  from ._util import ArrayIndexer, check_input, validate_vector
  import warnings
label_desc: Use image node_id 5 for calling the MahalanobisMixin obj's underlying member method code with example usage: obj.get_metric() and returns: metric_fun, dist