Using LIME explainer and keep getting error: "Type Error : NumPy array is not JSON serializable"

31 views Asked by At

I'm training an intrusion detection system using explainable AI. I am trying to implement explanations using LIME but keep getting the same error. I have tried converting the array to JSON using various methods but everytime I do that I get an AttributeError: 'str' object has no attribute 'shape'. I am using jupyter notebook.

This is my code involving lime -

lime_explainer = lime_tabular.LimeTabularExplainer(training_data = 
X_train, mode = "classification", feature_names = X_train[0:98], 
class_names = ['Dos','Probe','R2L','U2R','normal'])

explanation = lime_explainer.explain_instance(X_test[2], 
knn.predict_proba, top_labels=3)

explanation.show_in_notebook(show_table = True)
0

There are 0 answers