class_docstr:  Analyze label for insights:
  
   - classification: low cardinality classes detection
   - classification: classes present in test data, but not in the train data
   - regression: out-of-domain labels detection
  
   Note: this Analysis requires `problem_type` present in state.
   It can be detected/set via :py:class:`~autogluon.eda.analysis.dataset.ProblemTypeControl` component
  
  Parameters
   ----------
   low_cardinality_classes_threshold: int, default = 50
       Minimum class instances present in the dataset to consider marking a class as low-cardinality
   regression_ood_threshold: float, default = 0.01
       mark results as out-of-domain when test label range in regression task is beyond train data range + regression_ood_threshold margin,
       This is performed because some algorithms can't extrapolate beyond training data.
   class_imbalance_ratio_threshold: float, default = 0.4
      minority class proportion to detect as imbalance.
   parent: Optional[AbstractAnalysis], default = None
       parent Analysis
   children: Optional[List[AbstractAnalysis]], default None
       wrapped analyses; these will receive sampled `args` during `fit` call
   state: AnalysisState
       state object to perform check on
  
   Examples
   --------
   >>> import autogluon.eda.analysis as eda
   >>> import autogluon.eda.visualization as viz
   >>> import autogluon.eda.auto as auto
   >>> auto.analyze(
   >>> auto.analyze(train_data=..., test_data=..., label=..., anlz_facets=[
   >>>     eda.dataset.ProblemTypeControl(),
   >>>     eda.dataset.LabelInsightsAnalysis(low_cardinality_classes_threshold=50, regression_ood_threshold=0.01),
   >>> ], viz_facets=[
   >>>     viz.dataset.LabelInsightsVisualization()
   >>> ])
  
   See Also
   --------
   :py:class:`~autogluon.eda.analysis.dataset.ProblemTypeControl`
   :py:class:`~autogluon.eda.visualization.dataset.LabelInsightsVisualization`
class_docstr_tok: ["Analyze","label","for","insights",":","-","classification",":","low","cardinality","classes","detection","-","classification",":","classes","present","in","test","data",",","but","not","in","the","train","data","-","regression",":","out-of-domain","labels","detection","Note",":","this","Analysis","requires","`","problem_type","`","present","in","state",".","It","can","be","detected\/set","via",":","py",":","class",":","`","~autogluon.eda.analysis.dataset.ProblemTypeControl","`","component","Parameters","--","--","--","--","--","low_cardinality_classes_threshold",":","int",",","default","=","50","Minimum","class","instances","present","in","the","dataset","to","consider","marking","a","class","as","low-cardinality","regression_ood_threshold",":","float",",","default","=","0.01","mark","results","as","out-of-domain","when","test","label","range","in","regression","task","is","beyond","train","data","range","+","regression_ood_threshold","margin",",","This","is","performed","because","some","algorithms","ca","n't","extrapolate","beyond","training","data",".","class_imbalance_ratio_threshold",":","float",",","default","=","0.4","minority","class","proportion","to","detect","as","imbalance",".","parent",":","Optional","[","AbstractAnalysis","]",",","default","=","None","parent","Analysis","children",":","Optional","[","List","[","AbstractAnalysis","]","]",",","default","None","wrapped","analyses",";","these","will","receive","sampled","`","args","`","during","`","fit","`","call","state",":","AnalysisState","state","object","to","perform","check","on","Examples","--","--","--","--",">",">",">","import","autogluon.eda.analysis","as","eda",">",">",">","import","autogluon.eda.visualization","as","viz",">",">",">","import","autogluon.eda.auto","as","auto",">",">",">","auto.analyze","(",">",">",">","auto.analyze","(","train_data=","...",",","test_data=","...",",","label=","...",",","anlz_facets=","[",">",">",">","eda.dataset.ProblemTypeControl","(",")",",",">",">",">","eda.dataset.LabelInsightsAnalysis","(","low_cardinality_classes_threshold=50",",","regression_ood_threshold=0.01",")",",",">",">",">","]",",","viz_facets=","[",">",">",">","viz.dataset.LabelInsightsVisualization","(",")",">",">",">","]",")","See","Also","--","--","--","--",":","py",":","class",":","`","~autogluon.eda.analysis.dataset.ProblemTypeControl","`",":","py",":","class",":","`","~autogluon.eda.visualization.dataset.LabelInsightsVisualization","`"]
code: def _fit(
      self, state: AnalysisState, args: AnalysisState, **fit_kwargs
  ) -> None:
      label = args.label
      train_data = args.train_data
  
      s: Dict[str, Any] = {}
  
      if state.problem_type in [BINARY, MULTICLASS]:
          label_counts = train_data[label].value_counts()
          minority_class = label_counts[
              label_counts == label_counts.min()
          ].index.values[0]
          majority_class = label_counts[
              label_counts == label_counts.max()
          ].index.values[0]
          minority_class_imbalance_ratio = min(label_counts) / max(
              label_counts
          )
  
          # Low-cardinality class detection
          label_counts = label_counts[
              label_counts < self.low_cardinality_classes_threshold
          ].to_dict()
          if len(label_counts) > 0:
              s["low_cardinality_classes"] = {
                  "instances": label_counts,
                  "threshold": self.low_cardinality_classes_threshold,
              }
  
          # Class imbalance detection
          if (
              minority_class_imbalance_ratio
              < self.class_imbalance_ratio_threshold
          ):
              s["minority_class_imbalance"] = {
                  "majority_class": majority_class,
                  "minority_class": minority_class,
                  "ratio": minority_class_imbalance_ratio,
              }
  
          # Classes not found in test_data
          if self._test_data_with_label_present(args, label):
              train_labels = set(train_data[label].unique())
              test_labels = set(args.test_data[label].unique())
              if sorted(train_labels) != sorted(test_labels):
                  missing_classes = test_labels.difference(train_labels)
                  s["not_present_in_train"] = missing_classes
      elif (
          state.problem_type in [REGRESSION]
      ) and self._test_data_with_label_present(args, label):
          # Out-of-domain range detection
          test_data = args.test_data
          label_min, label_max = np.min(train_data[label]), np.max(
              train_data[label]
          )
          padding = (
              np.abs(label_max - label_min)
              * self.regression_ood_threshold
          )
          df_ood = args.test_data[
              (test_data[label] < label_min - padding)
              | (test_data[label] > label_max + padding)
          ]
  
          if len(df_ood) > 0:
              s["ood"] = {
                  "count": len(df_ood),
                  "train_range": [label_min, label_max],
                  "test_range": [
                      np.min(test_data[label]),
                      np.max(test_data[label]),
                  ],
                  "threshold": self.regression_ood_threshold,
              }
      if len(s) > 0:
          state.label_insights = s
  
imports: from __future__ import annotations
  from typing import Any, Dict, List, Optional, Set, Union
  import numpy
  import pandas
  from autogluon.common.features.infer_types import get_type_group_map_special, get_type_map_raw
  from autogluon.common.features.types import R_BOOL, R_CATEGORY, R_FLOAT, R_INT, R_OBJECT
  from ..state import AnalysisState
  from .base import AbstractAnalysis
  from autogluon.core.constants import BINARY, MULTICLASS, PROBLEM_TYPES_CLASSIFICATION, PROBLEM_TYPES_REGRESSION, REGRESSION
  from autogluon.core.utils import generate_train_test_split_combined, infer_problem_type
label_desc: Use image node_id 3 for calling the LabelInsightsAnalysis obj's underlying member method code with example usage: obj._fit(state, args) without return types