首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >数据集中特征较多时如何绘制Lime报表

数据集中特征较多时如何绘制Lime报表
EN

Stack Overflow用户
提问于 2020-09-17 20:01:37
回答 1查看 585关注 0票数 1

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

我的代码目前看起来像这样

代码语言:javascript
复制
 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)
EN

回答 1

Stack Overflow用户

发布于 2020-10-26 21:35:23

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

你应该像下面这样保存pyplot图-

代码语言:javascript
复制
fig = exp.as_pyplot_figure()

fig.savefig('lime_report.jpg')

为了将LIME解释保存为HTML格式,解释对象提供了一个方法-

代码语言:javascript
复制
exp.save_to_file('lime_report.html')
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63937620

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档