thomasp85 / lime

Local Interpretable Model-Agnostic Explanations (R port of original Python package)

Home Page:https://lime.data-imaginist.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not passing ... arguments to methods

alanault opened this issue · comments

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

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")

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, ... = ...)

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