class_docstr: Anomaly detection analysis.
  
  The analysis automatically creates cross-validation splits and fits detectors on each of them using
  `train_data` input. The scores produced for the training data are produced using out-of-folds predictions.
  All other datasets scores are produced using average of scores from detectors trained on individual folds (bag).
  
  Please note, the analysis expects the data is ready to for fitting; all numeric columns must not have NaNs.
  Pre-processing can be performed using :py:class:`~autogluon.eda.analysis.transform.ApplyFeatureGenerator`
  and :py:class:`~autogluon.eda.analysis.dataset.ProblemTypeControl` (see example for more details).
  
  State attributes
  
  - `anomaly_detection.scores.<dataset>`
      scores for each of the datasets passed into analysis (i.e. `train_data`, `test_data`)
  - `anomaly_detection.explain_rows_fns.<dataset>`
      if `store_explainability_data=True`, then analysis will store helper functions into this
      variable. The function can be used later via :py:meth:`~autogluon.eda.auto.simple.explain_rows`
      and automatically pre-populates `train_data`, `model` and `rows` parameters when called
      (see example for more details)
  
  
  Parameters
  ----------
  n_folds: int, default = 5
      number of folds to use when training detectors; default is 5 folds.
  store_explainability_data: bool, default = False
      if `True` analysis will store helper functions into this variable.
      The function can be used later via :py:meth:`~autogluon.eda.auto.simple.explain_rows`
      and automatically pre-populates `train_data`, `model` and `rows` parameters when called
      (see example for more details)
  parent: Optional[AbstractAnalysis], default = None
      parent Analysis
  children: List[AbstractAnalysis], default = []
      wrapped analyses; these will receive sampled `args` during `fit` call
  state: Optional[AnalysisState], default = None
      state to be updated by this fit function
  anomaly_detector_kwargs
      kwargs for :py:class:`~autogluon.eda.analysis.anomaly.AnomalyDetector`
  
  
  See Also
  --------
  :py:class:`~autogluon.eda.analysis.anomaly.AnomalyDetector`
  :py:class:`~autogluon.eda.visualization.anomaly.AnomalyScoresVisualization`
  :py:class:`~autogluon.eda.analysis.transform.ApplyFeatureGenerator`
  :py:class:`~autogluon.eda.analysis.dataset.ProblemTypeControl`
class_docstr_tok: ["Anomaly","detection","analysis",".","The","analysis","automatically","creates","cross-validation","splits","and","fits","detectors","on","each","of","them","using","`","train_data","`","input",".","The","scores","produced","for","the","training","data","are","produced","using","out-of-folds","predictions",".","All","other","datasets","scores","are","produced","using","average","of","scores","from","detectors","trained","on","individual","folds","(","bag",")",".","Please","note",",","the","analysis","expects","the","data","is","ready","to","for","fitting",";","all","numeric","columns","must","not","have","NaNs",".","Pre-processing","can","be","performed","using",":","py",":","class",":","`","~autogluon.eda.analysis.transform.ApplyFeatureGenerator","`","and",":","py",":","class",":","`","~autogluon.eda.analysis.dataset.ProblemTypeControl","`","(","see","example","for","more","details",")",".","State","attributes","-","`","anomaly_detection.scores.","<","dataset",">","`","scores","for","each","of","the","datasets","passed","into","analysis","(","i.e",".","`","train_data","`",",","`","test_data","`",")","-","`","anomaly_detection.explain_rows_fns.","<","dataset",">","`","if","`","store_explainability_data=True","`",",","then","analysis","will","store","helper","functions","into","this","variable",".","The","function","can","be","used","later","via",":","py",":","meth",":","`","~autogluon.eda.auto.simple.explain_rows","`","and","automatically","pre-populates","`","train_data","`",",","`","model","`","and","`","rows","`","parameters","when","called","(","see","example","for","more","details",")","Parameters","--","--","--","--","--","n_folds",":","int",",","default","=","5","number","of","folds","to","use","when","training","detectors",";","default","is","5","folds",".","store_explainability_data",":","bool",",","default","=","False","if","`","True","`","analysis","will","store","helper","functions","into","this","variable",".","The","function","can","be","used","later","via",":","py",":","meth",":","`","~autogluon.eda.auto.simple.explain_rows","`","and","automatically","pre-populates","`","train_data","`",",","`","model","`","and","`","rows","`","parameters","when","called","(","see","example","for","more","details",")","parent",":","Optional","[","AbstractAnalysis","]",",","default","=","None","parent","Analysis","children",":","List","[","AbstractAnalysis","]",",","default","=","[","]","wrapped","analyses",";","these","will","receive","sampled","`","args","`","during","`","fit","`","call","state",":","Optional","[","AnalysisState","]",",","default","=","None","state","to","be","updated","by","this","fit","function","anomaly_detector_kwargs","kwargs","for",":","py",":","class",":","`","~autogluon.eda.analysis.anomaly.AnomalyDetector","`","See","Also","--","--","--","--",":","py",":","class",":","`","~autogluon.eda.analysis.anomaly.AnomalyDetector","`",":","py",":","class",":","`","~autogluon.eda.visualization.anomaly.AnomalyScoresVisualization","`",":","py",":","class",":","`","~autogluon.eda.analysis.transform.ApplyFeatureGenerator","`",":","py",":","class",":","`","~autogluon.eda.analysis.dataset.ProblemTypeControl","`"]
docstr: Prepares arguments for :py:meth:`~autogluon.eda.auto.simple.explain_rows` call to explain anomaly scores contributions
  
  Parameters
  ----------
  args: AnalysisState,
      args from the analysis call (will be pre-populated)
  detector: AnomalyDetector
      detector to use for the prediction (will be pre-populated)
  dataset: str
      dataset to use (will be pre-populated)
  dataset_row_ids: List[any]
      list of row ids to explain from the specified `dataset`
  
  Returns
  -------
  Dict of arguments to pass into
  
  See Also
  --------
  :py:meth:`~autogluon.eda.auto.simple.explain_rows`
docstr_tok: ["Prepares","arguments","for",":","py",":","meth",":","`","~autogluon.eda.auto.simple.explain_rows","`","call","to","explain","anomaly","scores","contributions","Parameters","--","--","--","--","--","args",":","AnalysisState",",","args","from","the","analysis","call","(","will","be","pre-populated",")","detector",":","AnomalyDetector","detector","to","use","for","the","prediction","(","will","be","pre-populated",")","dataset",":","str","dataset","to","use","(","will","be","pre-populated",")","dataset_row_ids",":","List","[","any","]","list","of","row","ids","to","explain","from","the","specified","`","dataset","`","Returns","--","--","--","-","Dict","of","arguments","to","pass","into","See","Also","--","--","--","--",":","py",":","meth",":","`","~autogluon.eda.auto.simple.explain_rows","`"]
code: def explain_rows_fn(
      args: AnalysisState,
      detector: AnomalyDetector,
      dataset: str,
      dataset_row_ids: List[Any],
  ):
      """
      Prepares arguments for :py:meth:`~autogluon.eda.auto.simple.explain_rows` call to explain anomaly scores contributions
  
      Parameters
      ----------
      args: AnalysisState,
          args from the analysis call (will be pre-populated)
      detector: AnomalyDetector
          detector to use for the prediction (will be pre-populated)
      dataset: str
          dataset to use (will be pre-populated)
      dataset_row_ids: List[any]
          list of row ids to explain from the specified `dataset`
  
      Returns
      -------
      Dict of arguments to pass into
  
      See Also
      --------
      :py:meth:`~autogluon.eda.auto.simple.explain_rows`
  
  
      """
      missing_ids = [
          item
          for item in dataset_row_ids
          if item not in args[dataset].index
      ]
      assert (
          len(missing_ids) == 0
      ), f"The following ids are missing in `{dataset_row_ids}`: {missing_ids}"
      logger.info(
          "Please note that the feature values shown on the charts are transformed into an internal representation; "
          "they may be encoded or modified based on internal preprocessing. Refer to the original datasets for the actual feature values."
      )
      if dataset == "train_data":
          logger.warning(
              "Warning: The `train_data` dataset is used for explanation. The detector has seen the data, and estimates may be overly optimistic. "
              "Although the anomaly score in the explanation might not match, the magnitude of the features can still be utilized to "
              "evaluate the impact of the feature on the anomaly score."
          )
      return dict(
          train_data=args.train_data,
          model=detector,
          rows=args[dataset].loc[dataset_row_ids],
      )
  
imports: from __future__ import print_function
  import builtins
  import contextlib
  import logging
  from functools import partial
  from typing import Any, Dict, List, Optional
  import joblib
  import numpy
  import pandas
  from pyod.models.base import BaseDetector
  from pyod.models.copod import COPOD
  from pyod.models.iforest import IForest
  from pyod.models.lof import LOF
  from pyod.models.suod import SUOD
  from autogluon.common.utils.resource_utils import ResourceManager
  from autogluon.core.utils import CVSplitter
  from ..None import AnalysisState
  from .base import AbstractAnalysis
label_desc: Use image node_id 5 for calling the AnomalyDetectorAnalysis obj's underlying member method code with example usage: obj.explain_rows_fn(args, detector, dataset, dataset_row_ids) and returns: dict