简体   繁体   中英

How to plot Lime report when there is a lot of features in data-set

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM