marcotcr / lime

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

LimeTabularExplainer using pandas dataframe #554

Closed Lion-Mod closed 3 years ago

Lion-Mod commented 3 years ago

First timer with Lime.

Looking to make a prediction on a single row of data called to_predict

exp = LimeTabularExplainer(training_df, training_labels = ["Yes", "No"])
predict_fn = lambda x: model.predict_proba(x)
pred = exp.explain_instance(to_predict.values[0], predict_fn, num_features = 6)

My understanding is the issue if with the dataframe. It has both categorical and continuous features. After giving it a goog I'm scratching my head as to why it isn't working.

I understand it needs to be a 2d numpy array input to the Explainer but that doesn't seem to be working.

Could someone advise on using pandas dataframe for this instance?