docstr: Initialize the ErrorAnalysis Dashboard Input.
  
  :param explanation: An object that represents an explanation.
  :type explanation: ExplanationMixin
  :param model: An object that represents a model.
      It is assumed that for the classification case
      it has a method of predict_proba() returning
      the prediction probabilities for each
      class and for the regression case a method of predict()
      returning the prediction value.
  :type model: object
  :param dataset: A matrix of feature vector examples
  (# examples x # features), the same samples
      used to build the explanation.
      Will overwrite any set on explanation object already.
  :type dataset: numpy.ndarray or list[][] or pandas.DataFrame
  :param true_y: The true labels for the provided explanation.
      Will overwrite any set on explanation object already.
  :type true_y: numpy.ndarray or list[] or pandas.Series
  :param classes: The class names.
  :type classes: numpy.ndarray or list[]
  :param features: Feature names.
  :type features: numpy.ndarray or list[]
  :param categorical_features: The categorical feature names.
  :type categorical_features: list[str]
  :param true_y_dataset: The true labels for the provided dataset.
  Only needed if the explanation has a sample of instances from the
  original dataset.  Otherwise specify true_y parameter only.
  :type true_y_dataset: numpy.ndarray or list[] or pandas.Series
  :param pred_y: The predicted y values, can be passed in as an
      alternative to the model and explanation for a more limited
      view.
  :type pred_y: numpy.ndarray or list[] or pandas.Series
  :param pred_y_dataset: The predicted labels for the provided dataset.
      Only needed if providing a sample dataset for the UI while using
      the full dataset for the tree view and heatmap. Otherwise specify
      pred_y parameter only.
  :type pred_y_dataset: numpy.ndarray or list[] or pandas.Series
  :param model_task: Optional parameter to specify whether the model
      is a classification or regression model. In most cases, the
      type of the model can be inferred based on the shape of the
      output, where a classifier has a predict_proba method and
      outputs a 2 dimensional array, while a regressor has a
      predict method and outputs a 1 dimensional array.
  :type model_task: str
  :param metric: The metric name to evaluate at each tree node or
      heatmap grid.  Currently supported classification metrics
      include 'error_rate', 'recall_score' for binary
      classification and 'micro_recall_score' or
      'macro_recall_score' for multiclass classification,
      'precision_score' for binary classification and
      'micro_precision_score' or 'macro_precision_score'
      for multiclass classification, 'f1_score' for binary
      classification and 'micro_f1_score' or 'macro_f1_score'
      for multiclass classification, and 'accuracy_score'.
      Supported regression metrics include 'mean_absolute_error',
      'mean_squared_error', 'r2_score', and 'median_absolute_error'.
  :type metric: str
  :param max_depth: The maximum depth of the surrogate tree trained
      on errors.
  :type max_depth: int
  :param num_leaves: The number of leaves of the surrogate tree
      trained on errors.
  :type num_leaves: int
  :param min_child_samples: The minimal number of data required
      to create one leaf.
  :type min_child_samples: int
  :param sample_dataset: Dataset with fewer samples than the main
      dataset. Used to improve performance only when an
      Explanation object is not provided.  Used only if
      explanation is not specified for the dataset explorer.
      Specify less than 10k points for optimal performance.
  :type sample_dataset: pd.DataFrame or numpy.ndarray or list[][]
docstr_tok: ["Initialize","the","ErrorAnalysis","Dashboard","Input",".",":","param","explanation",":","An","object","that","represents","an","explanation",".",":","type","explanation",":","ExplanationMixin",":","param","model",":","An","object","that","represents","a","model",".","It","is","assumed","that","for","the","classification","case","it","has","a","method","of","predict_proba","(",")","returning","the","prediction","probabilities","for","each","class","and","for","the","regression","case","a","method","of","predict","(",")","returning","the","prediction","value",".",":","type","model",":","object",":","param","dataset",":","A","matrix","of","feature","vector","examples","(","#","examples","x","#","features",")",",","the","same","samples","used","to","build","the","explanation",".","Will","overwrite","any","set","on","explanation","object","already",".",":","type","dataset",":","numpy.ndarray","or","list","[","]","[","]","or","pandas.DataFrame",":","param","true_y",":","The","true","labels","for","the","provided","explanation",".","Will","overwrite","any","set","on","explanation","object","already",".",":","type","true_y",":","numpy.ndarray","or","list","[","]","or","pandas.Series",":","param","classes",":","The","class","names",".",":","type","classes",":","numpy.ndarray","or","list","[","]",":","param","features",":","Feature","names",".",":","type","features",":","numpy.ndarray","or","list","[","]",":","param","categorical_features",":","The","categorical","feature","names",".",":","type","categorical_features",":","list","[","str","]",":","param","true_y_dataset",":","The","true","labels","for","the","provided","dataset",".","Only","needed","if","the","explanation","has","a","sample","of","instances","from","the","original","dataset",".","Otherwise","specify","true_y","parameter","only",".",":","type","true_y_dataset",":","numpy.ndarray","or","list","[","]","or","pandas.Series",":","param","pred_y",":","The","predicted","y","values",",","can","be","passed","in","as","an","alternative","to","the","model","and","explanation","for","a","more","limited","view",".",":","type","pred_y",":","numpy.ndarray","or","list","[","]","or","pandas.Series",":","param","pred_y_dataset",":","The","predicted","labels","for","the","provided","dataset",".","Only","needed","if","providing","a","sample","dataset","for","the","UI","while","using","the","full","dataset","for","the","tree","view","and","heatmap",".","Otherwise","specify","pred_y","parameter","only",".",":","type","pred_y_dataset",":","numpy.ndarray","or","list","[","]","or","pandas.Series",":","param","model_task",":","Optional","parameter","to","specify","whether","the","model","is","a","classification","or","regression","model",".","In","most","cases",",","the","type","of","the","model","can","be","inferred","based","on","the","shape","of","the","output",",","where","a","classifier","has","a","predict_proba","method","and","outputs","a","2","dimensional","array",",","while","a","regressor","has","a","predict","method","and","outputs","a","1","dimensional","array",".",":","type","model_task",":","str",":","param","metric",":","The","metric","name","to","evaluate","at","each","tree","node","or","heatmap","grid",".","Currently","supported","classification","metrics","include","'error_rate","'",",","'recall_score","'","for","binary","classification","and","'micro_recall_score","'","or","'macro_recall_score","'","for","multiclass","classification",",","'precision_score","'","for","binary","classification","and","'micro_precision_score","'","or","'macro_precision_score'","for","multiclass","classification",",","'f1_score","'","for","binary","classification","and","'micro_f1_score","'","or","'macro_f1_score'","for","multiclass","classification",",","and","'accuracy_score","'",".","Supported","regression","metrics","include","'mean_absolute_error","'",",","'mean_squared_error","'",",","'r2_score","'",",","and","'median_absolute_error","'",".",":","type","metric",":","str",":","param","max_depth",":","The","maximum","depth","of","the","surrogate","tree","trained","on","errors",".",":","type","max_depth",":","int",":","param","num_leaves",":","The","number","of","leaves","of","the","surrogate","tree","trained","on","errors",".",":","type","num_leaves",":","int",":","param","min_child_samples",":","The","minimal","number","of","data","required","to","create","one","leaf",".",":","type","min_child_samples",":","int",":","param","sample_dataset",":","Dataset","with","fewer","samples","than","the","main","dataset",".","Used","to","improve","performance","only","when","an","Explanation","object","is","not","provided",".","Used","only","if","explanation","is","not","specified","for","the","dataset","explorer",".","Specify","less","than","10k","points","for","optimal","performance",".",":","type","sample_dataset",":","pd.DataFrame","or","numpy.ndarray","or","list","[","]","[","]"]
code: def __init__(
      self,
      explanation,
      model,
      dataset,
      true_y,
      classes,
      features,
      categorical_features,
      true_y_dataset,
      pred_y,
      pred_y_dataset,
      model_task,
      metric,
      max_depth,
      num_leaves,
      min_child_samples,
      sample_dataset,
  ):
      """Initialize the ErrorAnalysis Dashboard Input.
  
      :param explanation: An object that represents an explanation.
      :type explanation: ExplanationMixin
      :param model: An object that represents a model.
          It is assumed that for the classification case
          it has a method of predict_proba() returning
          the prediction probabilities for each
          class and for the regression case a method of predict()
          returning the prediction value.
      :type model: object
      :param dataset: A matrix of feature vector examples
      (# examples x # features), the same samples
          used to build the explanation.
          Will overwrite any set on explanation object already.
      :type dataset: numpy.ndarray or list[][] or pandas.DataFrame
      :param true_y: The true labels for the provided explanation.
          Will overwrite any set on explanation object already.
      :type true_y: numpy.ndarray or list[] or pandas.Series
      :param classes: The class names.
      :type classes: numpy.ndarray or list[]
      :param features: Feature names.
      :type features: numpy.ndarray or list[]
      :param categorical_features: The categorical feature names.
      :type categorical_features: list[str]
      :param true_y_dataset: The true labels for the provided dataset.
      Only needed if the explanation has a sample of instances from the
      original dataset.  Otherwise specify true_y parameter only.
      :type true_y_dataset: numpy.ndarray or list[] or pandas.Series
      :param pred_y: The predicted y values, can be passed in as an
          alternative to the model and explanation for a more limited
          view.
      :type pred_y: numpy.ndarray or list[] or pandas.Series
      :param pred_y_dataset: The predicted labels for the provided dataset.
          Only needed if providing a sample dataset for the UI while using
          the full dataset for the tree view and heatmap. Otherwise specify
          pred_y parameter only.
      :type pred_y_dataset: numpy.ndarray or list[] or pandas.Series
      :param model_task: Optional parameter to specify whether the model
          is a classification or regression model. In most cases, the
          type of the model can be inferred based on the shape of the
          output, where a classifier has a predict_proba method and
          outputs a 2 dimensional array, while a regressor has a
          predict method and outputs a 1 dimensional array.
      :type model_task: str
      :param metric: The metric name to evaluate at each tree node or
          heatmap grid.  Currently supported classification metrics
          include 'error_rate', 'recall_score' for binary
          classification and 'micro_recall_score' or
          'macro_recall_score' for multiclass classification,
          'precision_score' for binary classification and
          'micro_precision_score' or 'macro_precision_score'
          for multiclass classification, 'f1_score' for binary
          classification and 'micro_f1_score' or 'macro_f1_score'
          for multiclass classification, and 'accuracy_score'.
          Supported regression metrics include 'mean_absolute_error',
          'mean_squared_error', 'r2_score', and 'median_absolute_error'.
      :type metric: str
      :param max_depth: The maximum depth of the surrogate tree trained
          on errors.
      :type max_depth: int
      :param num_leaves: The number of leaves of the surrogate tree
          trained on errors.
      :type num_leaves: int
      :param min_child_samples: The minimal number of data required
          to create one leaf.
      :type min_child_samples: int
      :param sample_dataset: Dataset with fewer samples than the main
          dataset. Used to improve performance only when an
          Explanation object is not provided.  Used only if
          explanation is not specified for the dataset explorer.
          Specify less than 10k points for optimal performance.
      :type sample_dataset: pd.DataFrame or numpy.ndarray or list[][]
      """
      self._model = model
      self._categorical_features = categorical_features
      self._string_ind_data = None
      self._categories = []
      self._categorical_indexes = []
      self._is_classifier = is_classifier(model)
      self._dataframeColumns = None
      self.dashboard_input = {}
  
      model_available = model is not None
  
      if model_available and pred_y is not None:
          raise ValueError(
              "Only model or pred_y can be specified, not both"
          )
  
      self.dashboard_input[ENABLE_PREDICT] = model_available
  
      self.dashboard_input[
          ExplanationDashboardInterface.IS_CLASSIFIER
      ] = self._is_classifier
  
      is_pyspark = is_spark(dataset)
      if is_pyspark:
          self.setup_pyspark(
              model,
              dataset,
              true_y,
              classes,
              features,
              categorical_features,
              true_y_dataset,
              pred_y,
              pred_y_dataset,
              model_task,
              metric,
              max_depth,
              num_leaves,
              min_child_samples,
              sample_dataset,
              model_available,
          )
      else:
          self.setup_local(
              explanation,
              model,
              dataset,
              true_y,
              classes,
              features,
              categorical_features,
              true_y_dataset,
              pred_y,
              pred_y_dataset,
              model_task,
              metric,
              max_depth,
              num_leaves,
              min_child_samples,
              sample_dataset,
              model_available,
          )
      data = self.get_error_analysis_data(
          max_depth,
          num_leaves,
          min_child_samples,
          self._error_analyzer.metric,
          is_pyspark,
      )
      self.dashboard_input[
          ExplanationDashboardInterface.ERROR_ANALYSIS_DATA
      ] = data
  
imports: import traceback
  import numpy
  import pandas
  from erroranalysis._internal.constants import Metrics, display_name_to_metric, metric_to_display_name
  from erroranalysis._internal.error_analyzer import ModelAnalyzer, PredictionsAnalyzer
  from erroranalysis._internal.utils import is_spark
  from raiutils.data_processing import convert_to_list, serialize_json_safe
  from raiutils.models import is_classifier
  from responsibleai._interfaces import ErrorAnalysisData
  from .constants import ModelTask
  from .error_analysis_constants import ErrorAnalysisDashboardInterface, MethodConstants
  from .error_handling import _format_exception
  from .explanation_constants import ExplanationDashboardInterface, WidgetRequestResponseConstants
label_desc: Use image node_id 1 to create a new ErrorAnalysisDashboardInput object  with example: obj = ErrorAnalysisDashboardInput(explanation, model, dataset, true_y, classes, features, categorical_features, true_y_dataset, pred_y, pred_y_dataset, model_task, metric, max_depth, num_leaves, min_child_samples, sample_dataset)