【问题标题】:None Type is not iterable (RecurrentTabularExplainer)无 类型不可迭代(RecurrentTabularExplainer)
【发布时间】:2021-02-26 12:56:21
【问题描述】:

我正在尝试从 LIME 应用 Recurrent Tabular Explainar,但是,我不断得到 NoneType 不可迭代的输出。对于这个简单的最小示例,这甚至仍然存在:

from lime import lime_tabular

x_train = np.random.randint(0, 6249, size=(10, 6249,1))
yy_train = np.random.randint(0, 10, size=(10,1))

explainer = lime_tabular.RecurrentTabularExplainer(x_train, training_labels=yy_train)

任何人都可以帮助我并告诉我出了什么问题吗? 亲切的问候,

【问题讨论】:

标签: python tensorflow keras shap


【解决方案1】:

您缺少feature_names 参数。尽管它有一个默认值 (None),但您的 RecurrentTabularExplainer 类将始终需要该参数,因为它将对该列表执行迭代,以便分配数据列的名称。

由于您没有指定它,它会尝试遍历 None 对象,因此会出现错误。

用字符串列表填充feature_names 参数,即与训练数据中的列相对应的名称。

from lime import lime_tabular

x_train = np.random.randint(0, 6249, size=(10, 6249,1))
yy_train = np.random.randint(0, 10, size=(10,1))

explainer = lime_tabular.RecurrentTabularExplainer(x_train, feature_names=yy_names, training_labels=yy_train)

别忘了指定yy_names,比如yy_names = ['name1','name2','etc'...]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-22
    • 2019-07-02
    • 2021-02-13
    • 1970-01-01
    • 1970-01-01
    • 2022-11-30
    • 1970-01-01
    • 2020-10-31
    相关资源
    最近更新 更多