I'm dealing with a Deep learning model requiring as input a 4D array and I would like to use LIME to get some explainability on my results
I'm using lime_tabular.RecurrentTabularExplainer but it requires as training data a 3D numpy array, but my training data are a 4D array.
I tried with this code
from lime.lime_tabular import RecurrentTabularExplainer
explainer = RecurrentTabularExplainer(
X_train,
feature_names=reference_columns,
class_names=['No_error', 'Error'],
categorical_features=[0, 1]
#positive_class=0,
#method='exhaustive'
)
exp = explainer.explain_instance(
data_row = X_train[0,:,:,:],
classifier_fn = model_1.predict)
and I obtain the error : "too many values to unpack (expected 3)" since I'm passing a 4D array.
I also tried with this approach. Since my array is shaped as (5240, 57, 37, 1), I reshape it as (5240, 57, 37) when passing it to the RecurrentTabularExplainer
from lime import lime_tabular
data = X_train.reshape(X_train.shape[0], X_train.shape[1], X_train.shape[2])
explainer = lime_tabular.RecurrentTabularExplainer(
data,
training_labels = y_train,
feature_names = reference_columns,
discretize_continuous = True,
class_names = ['0','1'],
discretizer = 'decile')
exp = explainer.explain_instance(
data_row = X_train[0,:,:,:],
classifier_fn = model_1.predict)
exp.show_in_notebook()
but then I get this error in the explainer_instance: "ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [None, 57, 37]"
How can i solve this problem?