From 67b05071c535ca1611a3c3a4830137c4c973a78d Mon Sep 17 00:00:00 2001 From: Urja Pawar Date: Thu, 6 Oct 2022 19:31:22 +0100 Subject: [PATCH 1/2] Pytorch output support If 'yss' is output of a pytorch model, then this check is necessary in order to run a pytorch model trained on tabular dataset: if not isinstance(yss, np.ndarray): yss = yss.detach().numpy() --- lime/lime_tabular.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lime/lime_tabular.py b/lime/lime_tabular.py index 880f3d391..d84fc05a6 100644 --- a/lime/lime_tabular.py +++ b/lime/lime_tabular.py @@ -359,6 +359,8 @@ def explain_instance(self, ).ravel() yss = predict_fn(inverse) + if not isinstance(yss, np.ndarray): #pytorch output + yss = yss.detach().numpy() # for classification, the model needs to provide a list of tuples - classes # along with prediction probabilities From 07e11c1d6968be5918c654be71464eb22d0b7f05 Mon Sep 17 00:00:00 2001 From: Urja Pawar Date: Fri, 3 Mar 2023 00:43:27 +0000 Subject: [PATCH 2/2] Removed misleading line --- lime/lime_tabular.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lime/lime_tabular.py b/lime/lime_tabular.py index d84fc05a6..706eaed83 100644 --- a/lime/lime_tabular.py +++ b/lime/lime_tabular.py @@ -507,7 +507,6 @@ def __data_inverse(self, else: num_cols = data_row.shape[0] data = np.zeros((num_samples, num_cols)) - categorical_features = range(num_cols) if self.discretizer is None: instance_sample = data_row scale = self.scaler.scale_