marcotcr / lime

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

Interpreting pre-scaled data with LimeTabularExplainer (Keras Model) #337

Closed cdpierse closed 5 years ago

cdpierse commented 5 years ago

Hi,

I've recently started using LIME to understand some of the classifications of a keras model, however I'm struggling to understand how the TabularExplainer can give me some interpretable explanations when I provide it with data that is pre-scaled.

My data consists of both numerical and categorical features. I one hot encode the categorical features and the entirety of the dataset is then scaled using sklearn standard scaler. My model is trained on this scaled data and I provide the explainer with the scaled data for both train and test.

Is there a way to pass a fitted scaler to explainer in such a way that I possibly could inverse_transform? Or have I misinterpreted the mechanics of LIME in some way?

Thanks!

marcotcr commented 5 years ago

What you can do is wrap the encoder into the prediction function, and use the non-encoded data with LimeTabularExplainer. See #323

cdpierse commented 5 years ago

That's great thank you, sorry for the late response.