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","."]
code: def _get_dataset(self):
      dashboard_dataset = Dataset()
      dashboard_dataset.task_type = self.task_type
      dashboard_dataset.categorical_features = self.categorical_features
      dashboard_dataset.class_names = convert_to_list(self._classes)
      dashboard_dataset.is_large_data_scenario = (
          True if self._large_test is not None else False
      )
      dashboard_dataset.use_entire_test_data = False
  
      dashboard_dataset.tabular_dataset_metadata = (
          TabularDatasetMetadata()
      )
      dashboard_dataset.tabular_dataset_metadata.is_large_data_scenario = (
          True if self._large_test is not None else False
      )
      dashboard_dataset.tabular_dataset_metadata.use_entire_test_data = (
          False
      )
      dashboard_dataset.tabular_dataset_metadata.num_rows = (
          len(self._large_test)
          if self._large_test is not None
          else len(self.test)
      )
      dashboard_dataset.tabular_dataset_metadata.feature_ranges = (
          self._feature_ranges
      )
  
      if self._feature_metadata is not None:
          dashboard_dataset.feature_metadata = (
              self._feature_metadata.to_dict()
          )
      else:
          dashboard_dataset.feature_metadata = None
  
      if hasattr(self, ManagerNames.DATA_BALANCE):
          dashboard_dataset.data_balance_measures = (
              self._data_balance_manager.get_data()
          )
  
      predicted_y = None
      feature_length = None
  
      dataset: pd.DataFrame = self.test.drop(
          [self.target_column], axis=1
      )
  
      if isinstance(dataset, pd.DataFrame) and hasattr(
          dataset, "columns"
      ):
          self._dataframeColumns = dataset.columns
      try:
          list_dataset = convert_to_list(dataset)
      except Exception as ex:
          raise ValueError("Unsupported dataset type") from ex
      if dataset is not None and self.model is not None:
          try:
              predict_dataset = dataset
              metadata = self._feature_metadata
              metadata_exists = metadata is not None
              dropped_features_exist = (
                  metadata_exists
                  and metadata.dropped_features is not None
              )
              if (
                  dropped_features_exist
                  and len(metadata.dropped_features) != 0
              ):
                  predict_dataset = predict_dataset.drop(
                      metadata.dropped_features, axis=1
                  )
              predicted_y = self._get_model_output(
                  input_data=predict_dataset,
                  purpose=MethodPurpose.PREDICTION,
              )
          except Exception as ex:
              model_method = self._get_model_method(
                  purpose=MethodPurpose.PREDICTION
              )
              raise ValueError(
                  f"Model does not support {model_method.__name__} method "
                  "for the given dataset type,"
              ) from ex
          try:
              predicted_y = convert_to_list(predicted_y)
          except Exception as ex:
              raise ValueError(
                  "Model prediction output of unsupported type,"
              ) from ex
      if predicted_y is not None:
          if (
              self.task_type == ModelTask.CLASSIFICATION
              and dashboard_dataset.class_names is not None
          ):
              predicted_y = [
                  dashboard_dataset.class_names.index(y)
                  for y in predicted_y
              ]
          dashboard_dataset.predicted_y = predicted_y
  
      row_length = 0
      if list_dataset is not None:
          row_length, feature_length = np.shape(list_dataset)
          if row_length > 100000:
              raise ValueError(
                  "Exceeds maximum number of rows"
                  "for visualization (100000)"
              )
          if feature_length > 1000:
              raise ValueError(
                  "Exceeds maximum number of features for"
                  " visualization (1000). Please regenerate the"
                  " explanation using fewer features or"
                  " initialize the dashboard without passing a"
                  " dataset."
              )
          dashboard_dataset.features = list_dataset
  
      true_y = self.test[self.target_column]
      if self.task_type == ModelTask.FORECASTING:
          try:
              # This assumes that there is only 1 datetime feature.
              if (
                  self._feature_metadata
                  and self._feature_metadata.datetime_features
                  and len(self._feature_metadata.datetime_features) >= 1
              ):
                  time_column_name = (
                      self._feature_metadata.datetime_features[0]
                  )
                  dashboard_dataset.index = convert_to_list(
                      pd.to_datetime(self.test[time_column_name]).apply(
                          lambda dt: dt.strftime(_STRF_TIME_FORMAT)
                      )
                  )
          except Exception as ex:
              raise ValueError(
                  "The datetime feature should be parseable by "
                  "pandas.to_datetime, ideally in ISO format,"
              ) from ex
  
      if true_y is not None and len(true_y) == row_length:
          if (
              self.task_type == "classification"
              and dashboard_dataset.class_names is not None
          ):
              true_y = [
                  dashboard_dataset.class_names.index(y) for y in true_y
              ]
          dashboard_dataset.true_y = convert_to_list(true_y)
  
      features = dataset.columns
  
      if features is not None:
          features = convert_to_list(features)
          if (
              feature_length is not None
              and len(features) != feature_length
          ):
              raise ValueError(
                  "Feature vector length mismatch:"
                  " feature names length differs"
                  " from local explanations dimension"
              )
          dashboard_dataset.feature_names = features
      dashboard_dataset.target_column = self.target_column
  
      model_method = self._get_model_method(
          purpose=MethodPurpose.PROBABILITY
      )
      if model_method is not None and dataset is not None:
          try:
              predict_dataset = dataset
              metadata = self._feature_metadata
              metadata_exists = metadata is not None
              dropped_features_exist = (
                  metadata_exists
                  and metadata.dropped_features is not None
              )
              if (
                  dropped_features_exist
                  and len(metadata.dropped_features) != 0
              ):
                  predict_dataset = predict_dataset.drop(
                      metadata.dropped_features, axis=1
                  )
              probability_y = model_method(predict_dataset)
          except Exception as ex:
              raise ValueError(
                  f"Model does not support {model_method.__name__} method"
                  " for given dataset type,"
              ) from ex
          try:
              probability_y = convert_to_list(probability_y)
          except Exception as ex:
              raise ValueError(
                  f"Model {model_method.__name__} "
                  "output of unsupported type,"
              ) from ex
          dashboard_dataset.probability_y = probability_y
  
      return dashboard_dataset
  
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 23 for calling the RAIInsights obj's underlying member method code with example usage: obj._get_dataset() and returns: dashboard_dataset