Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当数据集中有很多特征时,如何绘制石灰报告_Python_Machine Learning_Classification_Mpld3_Lime - Fatal编程技术网

Python 当数据集中有很多特征时,如何绘制石灰报告

Python 当数据集中有很多特征时,如何绘制石灰报告,python,machine-learning,classification,mpld3,lime,Python,Machine Learning,Classification,Mpld3,Lime,我正试图使用方法作为\u pyplot\u figure()来绘制lime报告分类算法,以从LimetabulareExplainer获得解释。它正在工作,但我正在使用mpld3库中的save_html()以html格式本地保存的数据太过压缩(实际上不可见)。 处理这种情况的任何其他方法都会有所帮助 我的代码目前看起来像 from lime.lime_tabular import LimeTabularExplainer model= LGBMClassifier(boosting_t

我正试图使用
方法作为\u pyplot\u figure()
来绘制lime报告分类算法,以从LimetabulareExplainer获得解释。它正在工作,但我正在使用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)
exp.as\u pyplot\u figure()
返回一个pyplot图(条形图)

您应该保存pyplot图,如下所示-

fig = exp.as_pyplot_figure()

fig.savefig('lime_report.jpg')
为了以HTML格式保存解释,解释对象提供了一个方法-

exp.save_to_file('lime_report.html')

是否有人知道如何将已保存的解释(例如从as_list()加载回LIME exp对象以进行可视化?