Reputation: 13
I'm trying to plot lime report classification algorithm using the method as_pyplot_figure()
for the explanation from LimeTabularExplainer. It is working but the data which i'm saving locally in html format using save_html()
from mpld3 library which is coming as too compressed ( no visible actually).
Any other way to handle this scenario, will be helpful.
My code currently looks like
from lime.lime_tabular import LimeTabularExplainer
model= LGBMClassifier(boosting_type='gbdt', class_weight=None,
colsample_bytree=1.0,
importance_type='split', learning_rate=0.1, max_depth=-1,
min_child_samples=20, min_child_weight=0.001, min_split_gain=0.0,
n_estimators=100, n_jobs=-1, num_leaves=31, objective=None,
random_state=None, reg_alpha=0.0, reg_lambda=0.0, silent=True,
subsample=1.0, subsample_for_bin=200000, subsample_freq=0)
predict_function = model.predict
explainer = LimeTabularExplainer(train_data,mode='classification')
exp = explainer.explain_instance(
data, predict_function)
fig = exp.as_pyplot_figure()
mpld3.save_html(fig, lime_report.html)
Upvotes: 1
Views: 3355
Reputation: 492
exp.as_pyplot_figure()
returns a pyplot figure (barchart).
You should save that pyplot figure as below-
fig = exp.as_pyplot_figure()
fig.savefig('lime_report.jpg')
To save the LIME explanation in HTML format, the explanation object provides a method -
exp.save_to_file('lime_report.html')
Upvotes: 1