LIME explain instance resulting in empty graph
See original GitHub issueHi. I’m working with a spark data frame and to be able to make use of LIME we had to make some modifications:
def new_predict_fn(data):
sdf = map(lambda x: (int(x[0]), Vectors.dense(x[0:])), data)
sdf = spark.createDataFrame(sdf, schema=["id", "features"]).select("features")
predictions = cv_model.transform(sdf).select("prediction")
return predictions.toPandas()["prediction"].values.reshape(-1)
lime_df_test = nsdf.select('features').toPandas()
lime_df_test = pd.DataFrame.from_records(lime_df_test['features'].tolist())
exp = explainer.explain_instance(lime_df_test.iloc[10].values, new_predict_fn, num_features=20)
display(exp.as_pyplot_figure())
However, when it results in an “empty” explanation:
[(‘3575 <= 2199.13’, 0.0), (‘3981 <= 2189.88’, 0.0), (‘3987 <= 2189.88’, 0.0), (‘4527 <= 93.00’, 0.0), (‘4003 <= 1.00’, 0.0), (‘4528 <= 0.00’, 0.0), (‘3824 <= 14000000.00’, 0.0), (‘4256 <= 2199.73’, 0.0), (‘3685 <= 2190.45’, 0.0), (‘3579 <= 2199.13’, 0.0)]
We are looking for some reason for this to happen. A simple test with the modifications mentioned above worked well, but using real data (with more than 3000) columns, we faced that problem. The only idea that comes to my mind is that LIME is not being able to explain an instance locally (?). But I’m not sure if that makes sense. I’m also wondering (now) if it’s not just a case that the weights are plotted with 1 decimal place of precision and if (how) I could change that.
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:21 (8 by maintainers)
Top GitHub Comments
Hi, I am having similar issue getting zeros in binary classification, Can I have some help please, Thanks
exp.as_list()
returns explanations for label 1 (that is the default parameter), i.e. positive is positive towards 1 and negative is negative towards 1. You can useexp.as_list(label=2)
or any other value if you care about a particular label. 1 is a good default for binary classification,top_labels=1
is a good default otherwise.