-
Notifications
You must be signed in to change notification settings - Fork 68
/
ExplanationDashboard.py
33 lines (27 loc) · 1.19 KB
/
ExplanationDashboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
"""Defines the Explanation dashboard class."""
from .ExplanationWidget import ExplanationWidget
from IPython.display import display
class ExplanationDashboard(object):
"""The dashboard class, wraps the dashboard component."""
def __init__(self, explanation):
"""Initialize the Explanation Dashboard for a single sentence."""
local_importance_values = list(explanation._local_importance_values)
classNames = list(explanation._classes)
text = list(explanation._features)
prediction = [
0 if name == explanation._predicted_label else 1 for name in classNames
]
# ground_truth = explanation._true_label
self._widget_instance = ExplanationWidget()
self._widget_instance.value = {
"text": text,
"prediction": prediction,
"classNames": classNames,
"localExplanations": local_importance_values,
}
display(self._widget_instance)
def _show(self):
display(self._widget_instance)