thomasp85 / lime

Local Interpretable Model-Agnostic Explanations (R port of original Python package)
https://lime.data-imaginist.com/
Other
486 stars 110 forks source link

Maybe bug and solution: feature_select = "none" #141

Closed ruizcrp closed 5 years ago

ruizcrp commented 5 years ago

Hello,

I am wondering, whether there might be a small bug linked to the selection of "none" for the attribute of feature_select.

In the file lime.R in the function select_features there is a select-clause that contains in line 96 the following code: none = seq_len(nrow(x)),

It seems to me that this should read: none = seq_len(ncol(x)),

Because the matrix that is given in (called "perm" in the code) contains in the rows the permutations and in the columns the variables.

And I guess that the code should say: take all the variables.

In the following way an error can be reproduced, because it will chose the number of permutations (which by standard is 5000) instead of the number of variables:

example(explain)
explain(iris_test, explanation, n_labels = 1, n_features=2,feature_select="none")

And here it works because n_permutations is set to 3 (so that the nrow(x) is below the number of variables in the iris dataset): explain(iris_test, explanation, n_labels = 1,n_features=2,n_permutations=3,feature_select="none")

Kind regards!

thomasp85 commented 5 years ago

Thanks