class_docstr: Class for explanation aggregator. It aggregates the explanations based on classes, feature and scores.
docstr: Feed explanation into the aggregator for further analysis
  
  Args:
      explanation: dict, the pre-defined format as the output in `xai.explainer.utils.explanation_to_json`
code: def feed(self, explanation: Dict):
      """
      Feed explanation into the aggregator for further analysis
  
      Args:
          explanation: dict, the pre-defined format as the output in `xai.explainer.utils.explanation_to_json`
      """
      if OUTPUT.EXPLANATION in explanation:
          # Regression schema
          _ = self.get_feature_names(explanation[OUTPUT.EXPLANATION])
      else:
          # Classification schema
          for _label, _exp in explanation.items():
              if type(_exp) != dict:
                  raise InvalidExplanationFormat(_exp)
              if OUTPUT.EXPLANATION not in _exp.keys():
                  raise InvalidExplanationFormat(_exp)
              if type(_exp[OUTPUT.EXPLANATION]) != list:
                  raise InvalidExplanationFormat(_exp)
              _ = self.get_feature_names(_exp[OUTPUT.EXPLANATION])
  
      if OUTPUT.EXPLANATION in explanation:
          # Regression schema
          # To follow downstream schema, we set the "label" of regression prediction to 'NA'
          _label = "NA"
          if (
              explanation[OUTPUT.PREDICTION]
              > self._confidence_threshold
          ):
              self._explanation_list[_label].append(
                  {
                      item[OUTPUT.FEATURE]: item[OUTPUT.SCORE]
                      for item in explanation[OUTPUT.EXPLANATION]
                  }
              )
              self._class_counter[_label] += 1
      else:
          # Classification schema
          for _label, _exp in explanation.items():
              if _exp[OUTPUT.PREDICTION] > self._confidence_threshold:
                  self._explanation_list[_label].append(
                      {
                          item[OUTPUT.FEATURE]: item[OUTPUT.SCORE]
                          for item in _exp[OUTPUT.EXPLANATION]
                      }
                  )
                  self._class_counter[_label] += 1
      self._total_count += 1
  
file_path: contextual-ai/xai/model/interpreter/explanation_aggregator.py
imports: import operator
  from collections import defaultdict, Counter
  from typing import Dict, Tuple, List, Set
  from xai.explainer.constants import OUTPUT
  from xai.model.interpreter.exceptions import InvalidExplanationFormat, MutipleScoresFoundForSameFeature, UnsupportedMethodType, InvalidArgumentError
label_desc: Use image node_id 3 for calling the ExplanationAggregator obj's underlying member method code with example usage: obj.feed(explanation) without return types