我将this数据读入一个numpy数组并将其拆分为折叠。数据包含27,558张图像。 (已感染13779-未感染13779)。但是当我拟合模型并对其进行评估时,classification_report
说:
我使用了classification_report
,因为所有的折痕都连接在一起了。这是我使用的方法:
originalclass = []
predictedclass = []
kfold = StratifiedKFold(n_splits = folds, shuffle = True, random_state = random_state)
for train_index, test_index in kfold.split(data, labels):
fold_num = fold_num + 1
x_train, x_test = data[train_index], data[test_index]
y_train, y_test = labels[train_index], labels[test_index]
y_train = np_utils.to_categorical(y_train, num_classes = classes)
y_test = np_utils.to_categorical(y_test, num_classes = classes)
model = CNNbuild(optimizer = "Adam", activation = "softmax")
histAdam[str(fold_num)] = model.fit(x_train, y_train, epochs = epochs, batch_size = batch_size, validation_data=(x_test, y_test))
originalclass.extend(y_test)
predictedclass.extend(model.predict(x_test))
y_predB = np.argmax(predictedclass, axis=1)
y_testB = np.argmax(originalclass, axis=1)
print(classification_report(y_testB, y_predB, target_names=target_names))