I read this data into a numpy array and split it to folds. The data contains 27,558 images. (13779 infected - 13779 uninfected). But when I fit the model and evaluate it, the classification_report says:

  • 13781 infected(0),
  • 13779(1) uninfected.

classification_report

I used classification_report as all folds are joined. This is the method I've used:

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))

0 Answers