使用eli5使用keras计算神经网络特征重要性时的问题

问题描述

一个RBF神经网络模型进行预测,输入层包含5个变量,输出层包含一个变量,使用keras,编写程序获取特征重要性,如下:

def build_classifier():
    tube_par_X_train = pd.read_csv('Dataset/agstt_x_train.csv').iloc[:,1:].values
    sc_X = StandardScaler()
    sc_rbf_tube_par_X_train = sc_X.fit_transform(tube_par_X_train)
    model = Sequential()
    rbflayer = RBFLayer(64,initializer=InitCentersRandom(sc_rbf_tube_par_X_train),betas=0.6,input_shape=(5,))
    model.add(rbflayer)
    model.add(Dense(1,activation='linear'))

    model.compile(loss='mean_squared_error',optimizer=RMSprop(),metrics=['acc','mae'])
    return model

...


my_model = KerasRegressor(build_fn=build_classifier)
my_model.fit(sc_rbf_tube_par_X_train,sc_rbf_tube_eff_Y_train,batch_size=50,epochs=6000,verbose=0)

perm = PermutationImportance(my_model,random_state=1).fit(sc_rbf_tube_par_X_train,sc_rbf_tube_eff_Y_train)
print(perm.feature_importances_)
print(perm.feature_importances_std_)
eli5.show_weights(perm,feature_names=pd.DataFrame(sc_rbf_tube_par_X_train,columns=['solar radiation','ambient temperature','water inlet temperature','water flow rate','wind veLocity']).columns.tolist())

运行时,没有错误输出

[0.70284169 0.53042855 0.27219918 0.41412991 0.38019101]
this is the output of
 print(perm.feature_importances_)
[0.02672347 0.05186336 0.04829035 0.06341382 0.08717913]
this is the output of
 print(perm.feature_importances_std_)

然而:句子

eli5.show_weights(perm,'wind veLocity']).columns.tolist())

没有输出,什么都不显示,但是程序没有错误,请告诉我原因以及如何纠正

print(perm.feature_importances_) 的输出是:

[0.70284169 0.53042855 0.27219918 0.41412991 0.38019101]

这些系列数据是什么意思,在我看来,特征重要性的总和是 1,但在这输出中,

0.70284169 + 0.53042855 + 0.27219918 + 0.41412991 + 0.38019101 > 1

你能告诉我 perm.feature_importances_ 是什么意思吗

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)