Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions python/interpret_community/explanation/explanation.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ def _perf_dict(self, y, y_hat, i):
di["residual"] = int(y[i] == y_hat[i])
else:
di["residual"] = y[i] - y_hat[i]
# TODO: for classification case these should be the probabilities
di["actual_score"] = y[i]
di["predicted_score"] = y_hat[i]
return di

def _convert_local_importances_to_dense_list(self):
Expand Down Expand Up @@ -619,9 +622,8 @@ def selector(self):
:return: The selector as a pandas dataframe of records.
:rtype: pandas.DataFrame
"""
predicted = self._eval_y_predicted
dataset_shape = np.empty((self.num_examples, 1))
return gen_local_selector(dataset_shape, None, predicted.flatten())
data = self.data(key=-1)[InterpretData.SPECIFIC]
return gen_local_selector(data)

@classmethod
def _does_quack(cls, explanation):
Expand Down
9 changes: 3 additions & 6 deletions python/interpret_community/widget/explanation_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------

"""Defines the Explanation dashboard class."""
"""Defines the DEPRECATED Explanation dashboard class."""

import warnings

Expand Down Expand Up @@ -52,8 +52,5 @@ def __init__(self, explanation, model=None, *, dataset=None,
true_y=None, classes=None, features=None, port=None,
datasetX=None, trueY=None, locale=None, public_ip=None,
with_credentials=False, use_cdn=None):
if use_cdn is not None:
warnings.warn("""use_cdn parameter is deprecated, cdn has been deleted.
Constructor parameter will be removed in the future""")
warnings.warn("""ExplanationDashboard in interpret-community package is deprecated and removed.
Please use the ExplanationDashboard from raiwidgets package instead.""")
warnings.warn("ExplanationDashboard in interpret-community package is deprecated and removed."
"Please use the ExplanationDashboard from raiwidgets package instead.")
3 changes: 3 additions & 0 deletions requirements-vis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ prompt-toolkit>=2.0.0
greenlet==0.4.17
gevent==20.9.0
raiwidgets
# used by interpret show method
dash
dash-cytoscape
25 changes: 25 additions & 0 deletions test/test_explanation_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from interpret_community.mimic.models.lightgbm_model import LGBMExplainableModel
from interpret_community.common.constants import ModelTask
from raiwidgets import ExplanationDashboard
from interpret import show
from interpret_community.widget import ExplanationDashboard as OldExplanationDashboard
from common_utils import (create_lightgbm_classifier, create_sklearn_svm_classifier,
create_cancer_data, create_cancer_data_booleans)

Expand Down Expand Up @@ -79,3 +81,26 @@ def test_boolean_labels(self, mimic_explainer):
features=feature_names, classes=target_names)
explanation = explainer.explain_local(x_test)
ExplanationDashboard(explanation, model, dataset=x_test, true_y=y_test)

def test_old_explanation_dashboard(self, mimic_explainer):
# Validate old explanation dashboard namespace works but only prints a warning
x_train, x_test, y_train, y_test, feature_names, target_names = create_cancer_data()
# Fit an SVM model
model = create_sklearn_svm_classifier(x_train, y_train)
explainer = mimic_explainer(model, x_train, LGBMExplainableModel,
features=feature_names, classes=target_names)
explanation = explainer.explain_local(x_test)
err = ("ExplanationDashboard in interpret-community package is deprecated and removed."
"Please use the ExplanationDashboard from raiwidgets package instead.")
with pytest.warns(UserWarning, match=err):
OldExplanationDashboard(explanation, model, dataset=x_test, true_y=y_test)

def test_interpret_dashboard(self, mimic_explainer):
# Validate our explanation works with the interpret dashboard
x_train, x_test, y_train, y_test, feature_names, target_names = create_cancer_data()
# Fit an SVM model
model = create_sklearn_svm_classifier(x_train, y_train)
explainer = mimic_explainer(model, x_train, LGBMExplainableModel,
features=feature_names, classes=target_names)
explanation = explainer.explain_global(x_test)
show(explanation)