class_docstr: Defines the top-level RAIVisionInsights API.
  
  Use RAIVisionInsights to assess vision machine learning models in a
  single API.
class_docstr_tok: ["Defines","the","top-level","RAIVisionInsights","API",".","Use","RAIVisionInsights","to","assess","vision","machine","learning","models","in","a","single","API","."]
code: def _get_dataset(self):
      dashboard_dataset = Dataset()
      tasktype = self.task_type
      classification_tasks = [
          ModelTask.IMAGE_CLASSIFICATION,
          ModelTask.MULTILABEL_IMAGE_CLASSIFICATION,
          ModelTask.OBJECT_DETECTION,
      ]
      is_classification_task = self.task_type in classification_tasks
      if isinstance(self.task_type, Enum):
          tasktype = self.task_type.value
      dashboard_dataset.task_type = tasktype
      categorical_features = self._feature_metadata.categorical_features
      if categorical_features is None:
          categorical_features = []
      dashboard_dataset.categorical_features = categorical_features
      dashboard_dataset.class_names = convert_to_list(self._classes)
  
      if is_classification_task:
          if self.automl_image_model:
              dataset = np.array(
                  self.test.drop([self.target_column], axis=1)
                  .iloc[:, 0]
                  .tolist()
              )
  
              if tasktype == ModelTask.OBJECT_DETECTION.value:
                  dataset = pd.DataFrame(
                      data=[
                          [
                              x
                              for x in get_base64_string_from_path(
                                  img_path, return_image_size=True
                              )
                          ]
                          for img_path in dataset
                      ],
                      columns=[
                          MLFlowSchemaLiterals.INPUT_COLUMN_IMAGE,
                          MLFlowSchemaLiterals.INPUT_IMAGE_SIZE,
                      ],
                  )
              else:
                  dataset = pd.DataFrame(
                      data=[
                          get_base64_string_from_path(img_path)
                          for img_path in dataset
                      ],
                      columns=[MLFlowSchemaLiterals.INPUT_COLUMN_IMAGE],
                  )
          else:
              dataset = get_images(
                  self.test, self.image_mode, self._transformations
              )
      else:
          raise ValueError(
              "Unknown task type: {}".format(self.task_type)
          )
      predicted_y = None
      if dataset is not None and self._wrapped_model is not None:
          try:
              predicted_y = self._wrapped_model.predict(dataset)
          except Exception as ex:
              msg = (
                  "Model does not support predict method for given "
                  "dataset type"
              )
              raise ValueError(msg) 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 is_classification_task:
              predicted_y = self._convert_labels(
                  predicted_y, dashboard_dataset.class_names
              )
          dashboard_dataset.predicted_y = predicted_y
      row_length = len(dataset)
  
      dashboard_dataset.features = self._ext_test
  
      true_y = self.test[self.target_column]
      if true_y is not None and len(true_y) == row_length:
          true_y = convert_to_list(true_y)
          if is_classification_task:
              true_y = self._convert_labels(
                  true_y, dashboard_dataset.class_names
              )
          dashboard_dataset.true_y = true_y
  
      dashboard_dataset.feature_names = self._ext_features
      dashboard_dataset.target_column = self.target_column
  
      column_names = list(self.test.columns)
      if IMAGE in column_names:
          images = self.test[:].image
      elif IMAGE_URL in column_names:
          images = self.test[:].image_url
      else:
          raise ValueError("No image column found in test data")
      encoded_images = []
      image_dimensions = []
  
      for _, image in enumerate(images):
          if isinstance(image, str):
              image = get_image_from_path(image, self.image_mode)
          if isinstance(image, list):
              image = np.array(image)
          s = io.BytesIO()
          # IMshow only accepts floats in range [0, 1]
          try:
              image /= 255
          except Exception:
              # In-place divide can fail for certain types
              image = image / 255
          axes = pl.gca()
          axes.get_xaxis().set_visible(False)
          axes.get_yaxis().set_visible(False)
  
          pl.imshow(image)
          # resize image as optimization
          size = pl.gcf().get_size_inches()
          curr_width = size[0]
          curr_height = size[1]
          image_dimensions.append([image.shape[1], image.shape[0]])
          new_width = self.image_width
          if new_width is not None:
              factor = new_width / curr_width
              pl.gcf().set_size_inches(
                  (new_width, curr_height * factor)
              )
          pl.savefig(
              s, format="jpg", bbox_inches="tight", pad_inches=0.0
          )
          pl.clf()
          s.seek(0)
          b64_encoded = base64.b64encode(s.read())
          b64 = b64_encoded.decode(CommonTags.IMAGE_DECODE_UTF_FORMAT)
          encoded_images.append(b64)
  
      # passing to frontend to draw bounding boxes with the correct scale
      dashboard_dataset.image_dimensions = image_dimensions
  
      if len(encoded_images) > 0:
          dashboard_dataset.images = encoded_images
  
      if tasktype == ModelTask.OBJECT_DETECTION:
          d = dashboard_dataset
          dashboard_dataset.object_detection_predicted_y = d.predicted_y
          dashboard_dataset.object_detection_true_y = d.true_y
          dashboard_dataset.predicted_y = self._format_od_labels(
              dashboard_dataset.predicted_y,
              class_names=dashboard_dataset.class_names,
          )
  
          dashboard_dataset.true_y = self._format_od_labels(
              dashboard_dataset.true_y,
              class_names=dashboard_dataset.class_names,
          )
  
          dashboard_dataset.object_detection_labels = (
              self._generate_od_error_labels(
                  dashboard_dataset.object_detection_true_y,
                  dashboard_dataset.object_detection_predicted_y,
                  class_names=dashboard_dataset.class_names,
              )
          )
  
      return dashboard_dataset
  
imports: import base64
  import io
  import json
  import os
  import pickle
  import shutil
  import warnings
  from collections import defaultdict
  from enum import Enum
  from pathlib import Path
  from typing import Any, Optional
  import matplotlib.pyplot
  import numpy
  import pandas
  import torch
  from ml_wrappers import wrap_model
  from ml_wrappers.common.constants import Device
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  from vision_explanation_methods.error_labeling.error_labeling import ErrorLabeling, ErrorLabelType
  from erroranalysis._internal.cohort_filter import FilterDataWithCohortFilters
  from raiutils.data_processing import convert_to_list
  from raiutils.models.model_utils import SKLearn
  from responsibleai._interfaces import Dataset, RAIInsightsData
  from responsibleai._internal.constants import ManagerNames, Metadata, SerializationAttributes
  from responsibleai.exceptions import UserConfigValidationException
  from responsibleai.feature_metadata import FeatureMetadata
  from responsibleai.rai_insights.rai_base_insights import RAIBaseInsights
  from responsibleai.serialization_utilities import serialize_json_safe
  from responsibleai_vision.common.constants import CommonTags, ExplainabilityDefaults, ImageColumns, ImageModes, MLFlowSchemaLiterals, ModelTask
  from responsibleai_vision.managers.error_analysis_manager import ErrorAnalysisManager
  from responsibleai_vision.managers.explainer_manager import ExplainerManager
  from responsibleai_vision.utils.feature_extractors import extract_features
  from responsibleai_vision.utils.image_reader import get_base64_string_from_path, get_image_from_path, is_automl_image_model
  from responsibleai_vision.utils.image_utils import convert_images, get_images, transform_object_detection_labels
label_desc: Use image node_id 11 for calling the RAIVisionInsights obj's underlying member method code with example usage: obj._get_dataset() and returns: dashboard_dataset