docstr: Outlier detector for tabular data using the Mahalanobis distance.
  
  Parameters
  ----------
  threshold
      Mahalanobis distance threshold used to classify outliers.
  n_components
      Number of principal components used.
  std_clip
      Feature-wise stdev used to clip the observations before updating the mean and cov.
  start_clip
      Number of observations before clipping is applied.
  max_n
      Algorithm behaves as if it has seen at most max_n points.
  cat_vars
      Dict with as keys the categorical columns and as values
      the number of categories per categorical variable.
  ohe
      Whether the categorical variables are one-hot encoded (OHE) or not. If not OHE, they are
      assumed to have ordinal encodings.
  data_type
      Optionally specifiy the data type (tabular, image or time-series). Added to metadata.
docstr_tok: ["Outlier","detector","for","tabular","data","using","the","Mahalanobis","distance",".","Parameters","--","--","--","--","--","threshold","Mahalanobis","distance","threshold","used","to","classify","outliers",".","n_components","Number","of","principal","components","used",".","std_clip","Feature-wise","stdev","used","to","clip","the","observations","before","updating","the","mean","and","cov",".","start_clip","Number","of","observations","before","clipping","is","applied",".","max_n","Algorithm","behaves","as","if","it","has","seen","at","most","max_n","points",".","cat_vars","Dict","with","as","keys","the","categorical","columns","and","as","values","the","number","of","categories","per","categorical","variable",".","ohe","Whether","the","categorical","variables","are","one-hot","encoded","(","OHE",")","or","not",".","If","not","OHE",",","they","are","assumed","to","have","ordinal","encodings",".","data_type","Optionally","specifiy","the","data","type","(","tabular",",","image","or","time-series",")",".","Added","to","metadata","."]
code: def __init__(
      self,
      threshold: float = None,
      n_components: int = 3,
      std_clip: int = 3,
      start_clip: int = 100,
      max_n: int = None,
      cat_vars: dict = None,
      ohe: bool = False,
      data_type: str = "tabular",
  ) -> None:
      """
      Outlier detector for tabular data using the Mahalanobis distance.
  
      Parameters
      ----------
      threshold
          Mahalanobis distance threshold used to classify outliers.
      n_components
          Number of principal components used.
      std_clip
          Feature-wise stdev used to clip the observations before updating the mean and cov.
      start_clip
          Number of observations before clipping is applied.
      max_n
          Algorithm behaves as if it has seen at most max_n points.
      cat_vars
          Dict with as keys the categorical columns and as values
          the number of categories per categorical variable.
      ohe
          Whether the categorical variables are one-hot encoded (OHE) or not. If not OHE, they are
          assumed to have ordinal encodings.
      data_type
          Optionally specifiy the data type (tabular, image or time-series). Added to metadata.
      """
      super().__init__()
  
      if threshold is None:
          logger.warning(
              "No threshold level set. Need to infer threshold using `infer_threshold`."
          )
  
      self.threshold = threshold
      self.n_components = n_components
      self.std_clip = std_clip
      self.start_clip = start_clip
      self.max_n = max_n
  
      # variables used in mapping from categorical to numerical values
      # keys = categorical columns; values = numerical value for each of the categories
      self.cat_vars = cat_vars
      self.ohe = ohe
      self.d_abs: Dict = {}
  
      # initial parameter values
      self.clip: Optional[list] = None
      self.mean = 0
      self.C = 0
      self.n = 0
  
      # set metadata
      self.meta["detector_type"] = "outlier"
      self.meta["data_type"] = data_type
      self.meta["online"] = True
  
file_path: alibi-detect/alibi_detect/od/mahalanobis.py
imports: import logging
  import numpy
  from scipy.linalg import eigh
  from typing import Dict, Optional
  from alibi_detect.utils.discretizer import Discretizer
  from alibi_detect.utils.distance import abdm, mvdm, multidim_scaling
  from alibi_detect.utils.mapping import ohe2ord, ord2num
  from alibi_detect.base import BaseDetector, FitMixin, ThresholdMixin, outlier_prediction_dict
label_desc: Use image node_id 1 to create a new Mahalanobis object from inherited base classes: BaseDetector, FitMixin, ThresholdMixin with example: obj = Mahalanobis(threshold, n_components, std_clip, start_clip, max_n, cat_vars, ohe, data_type)