lime icon indicating copy to clipboard operation
lime copied to clipboard

background/filter dataset in LIME

Open BinDong314 opened this issue 3 years ago • 1 comments

Hi LIME community, Thanks for the help or any lead in advance.

One thing we are looking for is to provide a background data for LIME at the time of explanation of every instance. We are not sure if it is available in LIME? More specifically, it looks like the shap.KernelExplainer' data parameter. https://shap-lrjball.readthedocs.io/en/latest/generated/shap.KernelExplainer.html

One possible method is to provide feature_selection (e.g, highest_weights) for LimeTabularExplainer or explain_instance_with_data. But, it looks like LimeTabularExplainer needs to build the explainer for every instance, and explain_instance_with_data needs users to provide neighborhood_data etc.

Bests, Bin

BinDong314 avatar Nov 10 '22 21:11 BinDong314

Created a pull request here to address my issue. Please help to review it.

https://github.com/marcotcr/lime/pull/705

Some note:

Add predict_fn_accept_dense_only to explain_instance.

When data_row (of explain_instance) is scipy.sparse.matrix but the model was NOT trained with scipy.sparse.matrix, the predict_fn_accept_dense_only convert inverse to dense before call predict_fn (and then back to sparse after call predict_fn)

Bin [email protected]

BinDong314 avatar Nov 11 '22 18:11 BinDong314