class_docstr: Defines the top-level Model Analysis API.
  Use RAIInsights to analyze errors, explain the most important
  features, compute counterfactuals and run causal analysis in a
  single API.
class_docstr_tok: ["Defines","the","top-level","Model","Analysis","API",".","Use","RAIInsights","to","analyze","errors",",","explain","the","most","important","features",",","compute","counterfactuals","and","run","causal","analysis","in","a","single","API","."]
docstr: Creates an RAIInsights object.
  :param model: The model to compute RAI insights for.
      A model that implements sklearn-style predict or predict_proba
      or a function that accepts a 2d ndarray.
  :type model: object
  :param train: The training dataset including the label column.
  :type train: pandas.DataFrame
  :param test: The test dataset including the label column.
  :type test: pandas.DataFrame
  :param target_column: The name of the label column.
  :type target_column: str
  :param task_type: The task to run, can be `classification`,
      `regression`, or `forecasting`.
  :type task_type: str
  :param categorical_features: The categorical feature names.
      categorical_features is deprecated. Please provide categorical
      features via the feature_metadata argument instead.
      This argument will be removed after version 0.25
  :type categorical_features: Optional[List[str]]
  :param classes: The class labels in the training dataset
  :type classes: numpy.ndarray
  :param serializer: Picklable custom serializer with save and load
      methods for custom model serialization.
      The save method writes the model to file given a parent directory.
      The load method returns the deserialized model from the same
      parent directory.
  :type serializer: object
  :param maximum_rows_for_test: Limit on size of test data
      (for performance reasons)
  :type maximum_rows_for_test: int
  :param feature_metadata: Feature metadata for the train/test
                           dataset to identify different kinds
                           of features in the dataset.
  :type feature_metadata: Optional[FeatureMetadata]
docstr_tok: ["Creates","an","RAIInsights","object",".",":","param","model",":","The","model","to","compute","RAI","insights","for",".","A","model","that","implements","sklearn-style","predict","or","predict_proba","or","a","function","that","accepts","a","2d","ndarray",".",":","type","model",":","object",":","param","train",":","The","training","dataset","including","the","label","column",".",":","type","train",":","pandas.DataFrame",":","param","test",":","The","test","dataset","including","the","label","column",".",":","type","test",":","pandas.DataFrame",":","param","target_column",":","The","name","of","the","label","column",".",":","type","target_column",":","str",":","param","task_type",":","The","task","to","run",",","can","be","`","classification","`",",","`","regression","`",",","or","`","forecasting","`",".",":","type","task_type",":","str",":","param","categorical_features",":","The","categorical","feature","names",".","categorical_features","is","deprecated",".","Please","provide","categorical","features","via","the","feature_metadata","argument","instead",".","This","argument","will","be","removed","after","version","0.25",":","type","categorical_features",":","Optional","[","List","[","str","]","]",":","param","classes",":","The","class","labels","in","the","training","dataset",":","type","classes",":","numpy.ndarray",":","param","serializer",":","Picklable","custom","serializer","with","save","and","load","methods","for","custom","model","serialization",".","The","save","method","writes","the","model","to","file","given","a","parent","directory",".","The","load","method","returns","the","deserialized","model","from","the","same","parent","directory",".",":","type","serializer",":","object",":","param","maximum_rows_for_test",":","Limit","on","size","of","test","data","(","for","performance","reasons",")",":","type","maximum_rows_for_test",":","int",":","param","feature_metadata",":","Feature","metadata","for","the","train\/test","dataset","to","identify","different","kinds","of","features","in","the","dataset",".",":","type","feature_metadata",":","Optional","[","FeatureMetadata","]"]
code: def __init__(
      self,
      model: Optional[Any],
      train: pd.DataFrame,
      test: pd.DataFrame,
      target_column: str,
      task_type: str,
      categorical_features: Optional[List[str]] = None,
      classes: Optional[np.ndarray] = None,
      serializer: Optional[Any] = None,
      maximum_rows_for_test: int = 5000,
      feature_metadata: Optional[FeatureMetadata] = None,
      **kwargs,
  ):
      """Creates an RAIInsights object.
      :param model: The model to compute RAI insights for.
          A model that implements sklearn-style predict or predict_proba
          or a function that accepts a 2d ndarray.
      :type model: object
      :param train: The training dataset including the label column.
      :type train: pandas.DataFrame
      :param test: The test dataset including the label column.
      :type test: pandas.DataFrame
      :param target_column: The name of the label column.
      :type target_column: str
      :param task_type: The task to run, can be `classification`,
          `regression`, or `forecasting`.
      :type task_type: str
      :param categorical_features: The categorical feature names.
          categorical_features is deprecated. Please provide categorical
          features via the feature_metadata argument instead.
          This argument will be removed after version 0.25
      :type categorical_features: Optional[List[str]]
      :param classes: The class labels in the training dataset
      :type classes: numpy.ndarray
      :param serializer: Picklable custom serializer with save and load
          methods for custom model serialization.
          The save method writes the model to file given a parent directory.
          The load method returns the deserialized model from the same
          parent directory.
      :type serializer: object
      :param maximum_rows_for_test: Limit on size of test data
          (for performance reasons)
      :type maximum_rows_for_test: int
      :param feature_metadata: Feature metadata for the train/test
                               dataset to identify different kinds
                               of features in the dataset.
      :type feature_metadata: Optional[FeatureMetadata]
      """
      self._consolidate_categorical_features(
          categorical_features, feature_metadata
      )
  
      self._large_test = None
      if len(test) > maximum_rows_for_test:
          warnings.warn(
              f"The size of the test set {len(test)} is greater "
              "than the supported limit of "
              f"{maximum_rows_for_test}. Computing insights for "
              f"the first {maximum_rows_for_test} samples of "
              "the test set"
          )
          self._large_test = test.copy()
          test = test.copy()[0:maximum_rows_for_test]
  
      super(RAIInsights, self).__init__(
          model, train, test, target_column, task_type, serializer
      )
  
      self._predict_output = None
      self._forecast_output = None
      self._predict_proba_output = None
      self._forecast_quantiles_output = None
      self._large_predict_output = None
      self._large_forecast_output = None
      self._large_predict_proba_output = None
      self._large_forecast_quantiles_output = None
  
      self._validate_rai_insights_input_parameters(
          model=model,
          train=train,
          test=test,
          target_column=target_column,
          task_type=task_type,
          classes=classes,
          serializer=serializer,
          feature_metadata=self._feature_metadata,
          **kwargs,
      )
  
      self._classes = RAIInsights._get_classes(
          task_type=task_type,
          train=train,
          target_column=target_column,
          classes=classes,
      )
  
      self._feature_columns = test.drop(
          columns=[target_column]
      ).columns.tolist()
      self._feature_ranges = RAIInsights._get_feature_ranges(
          test=(
              self._large_test if self._large_test is not None else test
          ),
          categorical_features=self.categorical_features,
          feature_columns=self._feature_columns,
          datetime_features=self._feature_metadata.datetime_features,
      )
      (
          self._categories,
          self._categorical_indexes,
          self._category_dictionary,
          self._string_ind_data,
      ) = process_categoricals(
          all_feature_names=self._feature_columns,
          categorical_features=self.categorical_features,
          dataset=test.drop(columns=[target_column]),
      )
  
      if model is not None:
          # Cache predictions of the model
          self._set_model_outputs(
              input_data=self.get_test_data(test_data=test).drop(
                  columns=[target_column]
              ),
              large=False,
          )
  
          if self._large_test is not None:
              self._set_model_outputs(
                  input_data=self._large_test.drop(
                      columns=[target_column]
                  ),
                  large=True,
              )
      # keep managers at the end since they rely on everything above
      self._initialize_managers()
      self._try_add_data_balance()
  
imports: import json
  import pickle
  import warnings
  from enum import Enum
  from pathlib import Path
  from typing import Any, List, Optional, Union
  import numpy
  import pandas
  from erroranalysis._internal.cohort_filter import FilterDataWithCohortFilters
  from erroranalysis._internal.process_categoricals import process_categoricals
  from raiutils.data_processing import convert_to_list
  from raiutils.exceptions import SystemErrorException, UserConfigValidationException
  from raiutils.models import Forecasting, ModelTask, SKLearn
  from responsibleai._interfaces import Dataset, RAIInsightsData, TabularDatasetMetadata
  from responsibleai._internal._forecasting_wrappers import _wrap_model
  from responsibleai._internal.constants import FileFormats, ManagerNames, Metadata, SerializationAttributes
  from responsibleai.feature_metadata import FeatureMetadata
  from responsibleai.managers.causal_manager import CausalManager
  from responsibleai.managers.counterfactual_manager import CounterfactualManager
  from responsibleai.managers.data_balance_manager import DataBalanceManager
  from responsibleai.managers.error_analysis_manager import ErrorAnalysisManager
  from responsibleai.managers.explainer_manager import ExplainerManager
  from responsibleai.rai_insights.rai_base_insights import RAIBaseInsights
label_desc: Use image node_id 1 to create a new RAIInsights object from inherited base classes: RAIBaseInsights with example: obj = RAIInsights(model, train, test, target_column, task_type, categorical_features, classes, serializer, maximum_rows_for_test, feature_metadata)