docstr: The Mahalanobis outlier detection method.
  
  The Mahalanobis detector computes the directions of variation of a dataset and uses them to detect when points
  are outliers by checking to see if the points vary from dataset points in unexpected ways.
  
  When we fit the Mahalanobis detector we compute the covariance matrix of the reference data and its eigenvectors
  and eigenvalues. We filter small eigenvalues for numerical stability using the `min_eigenvalue` parameter. We
  then inversely weight each eigenvector by its eigenvalue.
  
  When we score test points we project them onto the eigenvectors and compute the l2-norm of the projected point.
  Because the eigenvectors are inversely weighted by the eigenvalues, the score will take into account the
  difference in variance along each direction of variation. If a test point lies along a direction of high
  variation then it must lie very far out to obtain a high score. If a test point lies along a direction of low
  variation then it doesn't need to lie very far out to obtain a high score.
  
  Parameters
  ----------
  min_eigenvalue
      Eigenvectors with eigenvalues below this value will be discarded. This is to ensure numerical stability.
  backend
      Backend used for outlier detection. Defaults to ``'pytorch'``. Options are ``'pytorch'``.
  device
      Device type used. The default tries to use the GPU and falls back on CPU if needed.
      Can be specified by passing either ``'cuda'``, ``'gpu'``, ``'cpu'`` or an instance of
      ``torch.device``.
  
  Raises
  ------
  NotImplementedError
      If choice of `backend` is not implemented.
docstr_tok: ["The","Mahalanobis","outlier","detection","method",".","The","Mahalanobis","detector","computes","the","directions","of","variation","of","a","dataset","and","uses","them","to","detect","when","points","are","outliers","by","checking","to","see","if","the","points","vary","from","dataset","points","in","unexpected","ways",".","When","we","fit","the","Mahalanobis","detector","we","compute","the","covariance","matrix","of","the","reference","data","and","its","eigenvectors","and","eigenvalues",".","We","filter","small","eigenvalues","for","numerical","stability","using","the","`","min_eigenvalue","`","parameter",".","We","then","inversely","weight","each","eigenvector","by","its","eigenvalue",".","When","we","score","test","points","we","project","them","onto","the","eigenvectors","and","compute","the","l2-norm","of","the","projected","point",".","Because","the","eigenvectors","are","inversely","weighted","by","the","eigenvalues",",","the","score","will","take","into","account","the","difference","in","variance","along","each","direction","of","variation",".","If","a","test","point","lies","along","a","direction","of","high","variation","then","it","must","lie","very","far","out","to","obtain","a","high","score",".","If","a","test","point","lies","along","a","direction","of","low","variation","then","it","does","n't","need","to","lie","very","far","out","to","obtain","a","high","score",".","Parameters","--","--","--","--","--","min_eigenvalue","Eigenvectors","with","eigenvalues","below","this","value","will","be","discarded",".","This","is","to","ensure","numerical","stability",".","backend","Backend","used","for","outlier","detection",".","Defaults","to","``","'pytorch","'","``",".","Options","are","``","'pytorch","'","``",".","device","Device","type","used",".","The","default","tries","to","use","the","GPU","and","falls","back","on","CPU","if","needed",".","Can","be","specified","by","passing","either","``","'cuda","'","``",",","``","'gpu","'","``",",","``","'cpu","'","``","or","an","instance","of","``","torch.device","``",".","Raises","--","--","--","NotImplementedError","If","choice","of","`","backend","`","is","not","implemented","."]
code: def __init__(
      self,
      min_eigenvalue: float = 1e-6,
      backend: Literal["pytorch"] = "pytorch",
      device: TorchDeviceType = None,
  ) -> None:
      """
      The Mahalanobis outlier detection method.
  
      The Mahalanobis detector computes the directions of variation of a dataset and uses them to detect when points
      are outliers by checking to see if the points vary from dataset points in unexpected ways.
  
      When we fit the Mahalanobis detector we compute the covariance matrix of the reference data and its eigenvectors
      and eigenvalues. We filter small eigenvalues for numerical stability using the `min_eigenvalue` parameter. We
      then inversely weight each eigenvector by its eigenvalue.
  
      When we score test points we project them onto the eigenvectors and compute the l2-norm of the projected point.
      Because the eigenvectors are inversely weighted by the eigenvalues, the score will take into account the
      difference in variance along each direction of variation. If a test point lies along a direction of high
      variation then it must lie very far out to obtain a high score. If a test point lies along a direction of low
      variation then it doesn't need to lie very far out to obtain a high score.
  
      Parameters
      ----------
      min_eigenvalue
          Eigenvectors with eigenvalues below this value will be discarded. This is to ensure numerical stability.
      backend
          Backend used for outlier detection. Defaults to ``'pytorch'``. Options are ``'pytorch'``.
      device
          Device type used. The default tries to use the GPU and falls back on CPU if needed.
          Can be specified by passing either ``'cuda'``, ``'gpu'``, ``'cpu'`` or an instance of
          ``torch.device``.
  
      Raises
      ------
      NotImplementedError
          If choice of `backend` is not implemented.
      """
      super().__init__()
  
      backend_str: str = backend.lower()
      BackendValidator(
          backend_options={"pytorch": ["pytorch"]},
          construct_name=self.__class__.__name__,
      ).verify_backend(backend_str)
  
      backend_cls = backends[backend]
      self.backend = backend_cls(min_eigenvalue, device=device)
  
      # set metadata
      self.meta["detector_type"] = "outlier"
      self.meta["data_type"] = "numeric"
      self.meta["online"] = False
  
file_path: alibi-detect/alibi_detect/od/_mahalanobis.py
imports: from typing import Dict, Any
  from alibi_detect.exceptions import _catch_error
  from typing_extensions import Literal
  import numpy
  from alibi_detect.base import BaseDetector, FitMixin, ThresholdMixin, outlier_prediction_dict
  from alibi_detect.od.pytorch import MahalanobisTorch
  from alibi_detect.utils.frameworks import BackendValidator
  from alibi_detect.version import __version__
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 1 to create a new Mahalanobis object from inherited base classes: BaseDetector, FitMixin, ThresholdMixin with example: obj = Mahalanobis(min_eigenvalue, backend, device)