captum icon indicating copy to clipboard operation
captum copied to clipboard

LIME attribute get all zero tensor

Open zhj123169 opened this issue 3 years ago • 1 comments

Thank you for providing this package for explaining models! I used lime to explain a FM-based model for recommendation.And the code is as follows:

explainer = Lime(model_initial) attr = explainer.attribute(inputs=model_input_lime, baselines=bg_data, additional_forward_args=(paras), n_samples = 80000, perturbations_per_eval=1, show_progress=True) in which model_input_lime is a tuple of tensor like (input_item_ids, input_item_values) as initial input and bg_data is a tuple of tensor like (bg_item_ids, bg_item_values) as background input. The shapes of these four tensors are (1,M,N).

And I want to get the relevance score of each features. I have checked model_input_lime and bg_data to make sure they are different. However, the final attr[0] and attr[1] are all zeros. How could I solve this problem? Thank you for any reply!

zhj123169 avatar Aug 05 '22 16:08 zhj123169

Hi @zhj123169 , it's possible that the default regularization term with Lasso regression may be too high, causing the attribution values to become 0. You can try providing interpretable_model as SkLearnLasso(alpha=0.0), setting the regularization term to 0 and check if this resolves the issue. More documentation regarding this parameter can be found here. Hope this helps!

vivekmig avatar Aug 15 '22 20:08 vivekmig