class_docstr: Metric Parser for clarify explainability
class_docstr_tok: ["Metric","Parser","for","clarify","explainability"]
docstr: Parse pdp data in clarify explainability.
  
  Args:
      explains (dict): Explains metric data.
docstr_tok: ["Parse","pdp","data","in","clarify","explainability",".","Args",":","explains","(","dict",")",":","Explains","metric","data","."]
code: def _parse_pdp(self, explains: dict):
      """Parse pdp data in clarify explainability.
  
      Args:
          explains (dict): Explains metric data.
      """
  
      def format_metric_data(
          feature: dict,
          distribution_value: List,
          prediction_values: List,
          x_axis_name: Union[str, list],
          graph_type: str,
      ):
          """Create metric entry.
  
          Args:
              feature (dict): Entry in pdp list.
              distribution_value (List): y values in data distribution graph.
              prediction_values (List): y values in data prediction graph.
              x_axis_name (Union[str, list]): X axis name.
              graph_type (str): Type of graph.
          """
          metric_data = []
          metric_data.append(
              {
                  "name": f"data_distribution - feature={feature['feature_name']}",
                  "type": graph_type,
                  "value": distribution_value,
                  "x_axis_name": x_axis_name,
                  "y_axis_name": "Data distribution",
              }
          )
          for idx, label_header in enumerate(feature["label_headers"]):
              metric_data.append(
                  {
                      "name": (
                          f"model_predictions - feature={feature['feature_name']}, "
                          f"label={label_header}"
                      ),
                      "type": graph_type,
                      "value": prediction_values[idx],
                      "x_axis_name": x_axis_name,
                      "y_axis_name": label_header,
                  }
              )
          return metric_data
  
      metric_groups = []
      if "pdp" not in explains:
          return metric_groups
  
      metric_data = []
      for feature in explains["pdp"]:
          if feature["data_type"] == "numerical":
              distribution_value = list(
                  zip(
                      feature["feature_values"],
                      feature["data_distribution"],
                  )
              )
              prediction_values = [
                  list(
                      zip(
                          feature["feature_values"],
                          feature["model_predictions"][i],
                      )
                  )
                  for i, _ in enumerate(feature["label_headers"])
              ]
              x_axis_name = feature["feature_name"]
              metric_data.extend(
                  format_metric_data(
                      feature=feature,
                      distribution_value=distribution_value,
                      prediction_values=prediction_values,
                      x_axis_name=x_axis_name,
                      graph_type="linear_graph",
                  )
              )
          if feature["data_type"] == "categorical":
              distribution_value = feature["data_distribution"]
              prediction_values = [
                  feature["model_predictions"][i]
                  for i, _ in enumerate(feature["label_headers"])
              ]
              x_axis_name = feature["feature_values"]
              metric_data.extend(
                  format_metric_data(
                      feature=feature,
                      distribution_value=distribution_value,
                      prediction_values=prediction_values,
                      x_axis_name=x_axis_name,
                      graph_type="bar_chart",
                  )
              )
  
      metric_groups.append(
          {"name": "explanations - pdp", "metric_data": metric_data}
      )
  
      return metric_groups
  
imports: from __future__ import absolute_import
  from abc import ABC, abstractmethod
  from enum import Enum
  from collections import defaultdict
  from typing import Union, List
  from sagemaker.model_card.schema_constraints import PYTHON_TYPE_TO_METRIC_VALUE_TYPE, METRIC_VALUE_TYPE_MAP, MetricTypeEnum
label_desc: Use image node_id 4 for calling the ClarifyExplainabilityParser obj's underlying member method code with example usage: obj._parse_pdp(explains) and returns: metric_groups, metric_data, metric_groups