model.interpreter.explanation_aggregator module¶
-
class
ExplanationAggregator
(confidence_threshold=0.8)[source]¶ Bases:
object
Class for explanation aggregator. It aggregates the explanations based on classes, feature and scores.
-
feed
(explanation: Dict)[source]¶ Feed explanation into the aggregator for further analysis
- Parameters
explanation – dict, the pre-defined format as the output in xai.explainer.utils.explanation_to_json
-
get_feature_names
(list_explanations: List[Dict]) → Set[source]¶ Get feature names for an explanation, plus schema validation :param list_explanations: List of explanations :type list_explanations: list
- Returns
(set) feature names
-
get_statistics
(stats_type: str = 'top_k', k: int = 5) → Tuple[Dict[int, Dict], int][source]¶ return statistics of explanations in the aggregator based on the type
- Parameters
stats_type –
str, not None. The pre-defined types of statistics. For now, it supports 3 types:
top_k: how often a feature appears in the top K features in the explanation
average_score: average score for each feature in the explanation
average_ranking: average ranking for each feature in the explanation
Default type is top_k.
k – int, not None. the k value for top_k method and average_ranking. It will be ignored if the stats type are not top_k or average_ranking. Default value of k is 5.
- Returns
A dictionary maps the label to its aggregated statistics. An integer to indicate the total number of explanations to generate the statistics.
-