【问题标题】:classification report in keraskeras中的分类报告
【发布时间】:2018-06-01 21:00:12
【问题描述】:

我正在使用分类报告来计算以下模型的准确率、召回率和 fscore

x_train = train[:,[3,4,5,6,7]]
x_test = test[:,[3,4,5,6,7]]
y_train = train[:,8]
y_test = test[:,8]

n = x_train.shape[0]
n2 = x_test.shape[0]
L = 32
X_train_seq = []
Y_train_seq = []
for k in range(n - L + 1):
    X_train_seq.append(x_train[k : k + L])
    Y_train_seq.append(y_train[k : k + L])

X_test_seq = []
Y_test_seq = []
for k1 in range(n2 - L + 1):
    X_test_seq.append(x_test[k1 : k1 + L])
    Y_test_seq.append(y_test[k1 : k1 + L])

X_train_seq = np.array(X_train_seq)
Y_train_seq = np.array(Y_train_seq)
X_test_seq = np.array(X_test_seq)
Y_test_seq = np.array(Y_test_seq)

model = Sequential()
model.add(LSTM(64, input_shape=(32, 5), activation='tanh'))
model.add(Dense(32, activation='sigmoid' ))
model.compile(loss='binary_crossentropy',
              optimizer='adam',
              metrics=['accuracy'])

hist = model.fit(X_train_seq, Y_train_seq, batch_size = 200, epochs = 15,
                 verbose = 2)
avg = np.mean(hist.history['acc'])
print('The Average Training Accuracy is', avg)
score=model.evaluate(X_test_seq, Y_test_seq, batch_size=200,verbose=2)
print(score)

y_pred=model.predict(X_test_seq, batch_size=200, verbose=2)
report = classification_report(Y_test_seq, y_pred.round())
print(report)

这里的问题是输出,我猜这不是真的,我不知道为什么! 这是输出的样本

 precision    recall  f1-score   support

0       0.35      0.11      0.17     30146
1       0.35      0.12      0.17     30146
2       0.35      0.12      0.17     30146
3       0.35      0.12      0.18     30146
4       0.35      0.12      0.18     30146
5       0.35      0.12      0.18     30146

为什么值非常低,虽然准确度是 94%

【问题讨论】:

    标签: keras deep-learning lstm rnn


    【解决方案1】:

    您不能只依赖准确度作为衡量标准。评估模型的指标很差。通常 EM 和 F 分数是对您的实际模型性能的完整且更具描述性的衡量标准。

    【讨论】:

      【解决方案2】:

      很可能在预测的类之间存在显着的不平衡,因此您的模型已经学会很好地预测多数类,但在少数类上却失败了,因此准确率高,召回率、精度等低。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-26
        • 2017-05-25
        • 2020-02-14
        • 2023-03-03
        • 1970-01-01
        • 1970-01-01
        • 2021-05-28
        • 2020-03-07
        相关资源
        最近更新 更多