【问题标题】:How to plot Lime report when there is a lot of features in data-set当数据集中有很多特征时如何绘制 Lime 报告
【发布时间】:2020-09-17 12:01:36
【问题描述】:

我正在尝试使用 as_pyplot_figure() 方法绘制石灰报告分类算法,以获得 LimeTabularExplainer 的解释。它正在工作,但我使用 mpld3 库中的 save_html() 以 html 格式在本地保存的数据压缩得太过压缩(实际上不可见)。 处理这种情况的任何其他方法都会有所帮助。

我的代码目前看起来像

 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)

【问题讨论】:

    标签: python machine-learning classification mpld3 lime


    【解决方案1】:

    exp.as_pyplot_figure() 返回一个 pyplot 图(条形图)。

    您应该将 pyplot 图形保存如下-

    fig = exp.as_pyplot_figure()
    
    fig.savefig('lime_report.jpg')
    

    要以 HTML 格式保存 LIME 说明,说明对象提供了一个方法 -

    exp.save_to_file('lime_report.html')
    

    【讨论】:

    • 有谁知道如何加载保存的解释,例如从 as_list() 回到 LIME exp 对象进行可视化?
    猜你喜欢
    • 2020-06-22
    • 2021-08-05
    • 2020-01-16
    • 1970-01-01
    • 1970-01-01
    • 2013-03-01
    • 2021-11-19
    • 2019-12-26
    • 1970-01-01
    相关资源
    最近更新 更多