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

Not passing ... arguments to methods #150

Closed alanault closed 5 years ago

alanault commented 5 years ago

Hi there,

I've written a predict_model class for my somewhat esoteric text model. I'd like to pass arguments to the underlying method using the lime function, but they don't seem to be passing down via ...

Looking at the underlying code, I'm not sure whether they're correctly being passed to the underlying method.

I'm building my explainer as:

explainer <- lime(test, model = model, country = "FR")

where I'd like "FR" to be passed to the underlying method. Although it's present in the explainer object, it doesn't seem to be passed to the method.

Any ideas, or am I fundamentally missing something?

Many thanks Alan

alanault commented 5 years ago

A-ha! resolved this.

Looks like I should pass the arguments through the lime::explain function rather than inside the explainer itself. i.e.

explanation <- lime::explain(x = test_dat,
                             explainer = explainer,
                             country = "FR")
alanault commented 5 years ago

Actually ... my bad, I was right first time. I had changed the underlying lime code to make this work.

I believe we're missing an ellipsis in the explain.character method.

line 98 misses the ellipsis which is needed to pass through additional arguments. It currently reads:

case_res <- predict_model(x = explainer$model, newdata = permutations_tokenized, type = o_type)

... and I believe it should say:

case_res <- predict_model(x = explainer$model, newdata = permutations_tokenized, type = o_type, ... = ...)

thomasp85 commented 5 years ago

Passing ellipsis on to the prediction function is not something that has been advertised, though it may be a good idea