1.生成解释器2.对局部点的解释3.显示详细信息图
1) pytorch2) jupyter notebook
1.生成解释器explainer = lime_tabular.LimetabularExplainer(
training_data,
mode='classification',
feature_names=None,
categorical_features=None,
verbose=False,
class_names=None)
training_data:训练机器学习模型的自变量数据
mode:模式,可选'classification'(分类)和'regression'(回归)
feature_names:特征的名称列表
categorical_features:索引列表,即用作线性化近似的特征只会由该列表中选中的特征组成
verbose:决定是否在使用explain_instance的时候输出详细信息
class_names:字符串列表,决定后续权重表的标题
2.对局部点的解释exp = explainer.explain_instance( data_row, predict_fn, top_labels=None, num_features=10)
data_row:一维ndarray,单个数据点(要解释的点)
predict_fn:待解释模型的预测函数
top_labels:若top_labels=k,则选取预测出的概率最高的k种情况来进行解释
num_features:若num_features=k,则选出k个最有效的特征来进行局部线性化
3.显示详细信息图 1) pytorchexp.as_pyplot_figure() plt.show()
查看LIME包explanation.py文件的as_pyplot_figure()函数,函数只绘制了图片,没有显示语句
2) jupyter notebookexp.show_in_notebook(show_table=True, show_all=False)



