I would like to expain Logistic regression model with LIME (mode as classification) but I got the error while using the explain_instance:
explainer_LIME = lime.lime_tabular.LimeTabularExplainer(X_train.values, feature_names=X_train.columns.values.tolist(), class_names=['0','1'], verbose=True, mode='classification' explainer_LIME.explain_instance(X_test.values[0], logreg.predict_proba(X_test)[:,:], num_features=9)
`—————————————————————————
TypeError Traceback (most recent call last)
~AppDataLocalTemp/ipykernel_20548/2338043217.py in
—-> 1 explainer_LIME.explain_instance(X_test.values[0], data_predict2, num_features=9)
~anaconda3libsite-packageslimelime_tabular.py in explain_instance(self, data_row, predict_fn, labels, top_labels, num_features, num_samples, distance_metric, model_regressor)
353 ).ravel()
354
–> 355 yss = predict_fn(inverse)
356
357 # for classification, the model needs to provide a list of tuples – classes
TypeError: ‘numpy.ndarray’ object is not callable
`
For the mode=regression, the code works fine (using predict instead of predic_proba). I would like to know if maybe shape of the logreg.predict_proba(X_test)[:,:] is a problem. The shape is 16141×2. Do I need to reshape it in [ [x1,x2], [x3 ,x4],….]?
The logreg.predict_proba(X_test)[:,:] looks like this:
array([[7.47973377e-01, 2.52026623e-01], [5.15730999e-05, 9.99948427e-01], [9.40554533e-01, 5.94454673e-02], ..., [1.15426339e-01, 8.84573661e-01], [3.78704880e-04, 9.99621295e-01], [1.81452222e-01, 8.18547778e-01]])
I have already tried some stuff I read but it didn’t work.
Thank you for help.
I tried to reshape it, convert into list of tuples but it didn’t work.