marcotcr / lime

Lime: Explaining the predictions of any machine learning classifier
BSD 2-Clause "Simplified" License
11.4k stars 1.79k forks source link

the output mapping of the explain_instance from lime does not match num_features #717

Closed jaycej1 closed 1 year ago

jaycej1 commented 1 year ago

Hey Lime dev, I am having an issue with one of my explainer output, I have a num_features set to 25 using the code below

lime_output = explainer.explain_instance(
        data_row=padded_tokens,
        classifier_fn=model.predict,
        labels=np.arange(num_labels),
        num_features=25,
        num_samples=num_samples
)

however, on my lime_output it only contain 23 elements out of the 25, like this [(1, -0.130737434980867), (3, 0.09073698632526585), (4, -0.010046931764647637), (5, -0.007087586992747926), (6, 0.08867941287664231), (7, 0.10368575650248872), (8, 0.08291221511496029), (9, -0.05641647941203233), (10, -0.03175563794505291), (11, -0.03422573793925312), (12, 0.00918590728171141), (13, -0.021994606990386495), (14, -0.011512976586281119), (15, -0.04977705050922405), (16, -0.024474892592748283), (17, -0.07695704999728427), (18, -0.011389719134079728), (19, 0.00024869478851676625), (20, -0.011244528340060731), (21, 0.014222563957588932), (22, -0.0013912997054544337), (23, 0.010861344102613621), (24, -0.021245405556340847)]

does anyone know why the other features are missing?

jaycej1 commented 1 year ago

Nevermind, this is because I am using feature_selection="lasso_path"