所以我试图将石灰解释拟合到计算预测的 kerns 模型中。数据集本身包含 6 个属性,用于将每个实例分类为“通过”(1)或“失败”(0)
模型本身如下所示:
model = Sequential()
model.add(Dense(6, input_dim=6, activation="sigmoid"))
model.add(Dense(8, activation="sigmoid"))
model.add(Dense(1, activation="softmax"))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(X_train_ker, y_train_ker, epochs=20, use_multiprocessing=True)
对于 LIME 实现,我尝试使用与 sklearn 模型大致相同的参数。
explainer = lime_tabular.LimeTabularExplainer(
training_data=np.array(X_train),
feature_names=X_train.columns,
class_names=[0, 1],
mode='classification'
)
X = X_test_ker.iloc[1]
exp = explainer.explain_instance(
data_row=X,
predict_fn=model_keras.predict_proba(X),
)
data = exp.as_pyplot_figure()
plt.tight_layout()
plt.show()
然而,这会产生以下 ValueError:
ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 6 but received input with shape (None, 1)
有什么想法可以解决这个问题,以便我实际上对我的模型有一些有用的见解吗?