LimeTabularExplainer类型错误:不可损坏类型:“切片”

2024-06-11 22:29:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用石灰包来解释预测模型。运行以下代码时请参阅错误:

# Create the LIME Explainer
explainer = lime.lime_tabular.LimeTabularExplainer(X_train_undersample feature_names = feature_names,class_names=['0','1'], kernel_width=3)

错误:

TypeError: unhashable type: 'slice'

有什么问题吗?在


Tags: the代码模型names错误create请参阅feature
2条回答

错误是因为您的X_train_欠采样是DataFrame stype。如果将DataFrame类型更改为数组类型(例如float64数组),就可以了。在

如果您的x_train是一个数据帧,请尝试如下方式传递它:

x_train_undersample.as_matrix()

相关问题 更多 >