How to get confusion matrix and precision of CNN model

I have trained a CNN with keras to detect if an image has a manhole inside or not. I want to get the confusion matrix and precision recall of my model but i dont know what is my real data and my predicted data.

This is the input I have:

Imports of datasets inside Drive
ds_negatives = np.loadtxt('/content/drive/MyDrive/Colab Notebooks/negative_depth.txt')
ds_positives = np.loadtxt('/content/drive/MyDrive/Colab Notebooks/positive_depth.txt')

#Labeled arrays for datasets
arrayceros = np.zeros(n_negatives_img)
arrayunos = np.ones(n_positives_img)

#Reshaping of datasets to convert separate them
arraynegativos= ds_negatives.reshape(( n_negatives_img, img_height, img_width,1))
arraypositivos= ds_positives.reshape((n_positives_img, img_height, img_width,1))

#Labeling datasets with the arrays
ds_negatives_target =, arrayceros))
ds_positives_target =, arrayunos))

#Concatenate 2 datasets and shuffle them
ds_concatenate = ds_negatives_target.concatenate(ds_positives_target)
datasetfinal = ds_concatenate.shuffle(n_total_img)

print("shape of positive data:",datasetfinal)
#24000 images for the training ds and 20000 for the validation ds
valid_ds_f = datasetfinal.take(10000)
train_ds_f = datasetfinal.skip(10000)

valid_ds = valid_ds_f.batch(12)
train_ds = train_ds_f.batch(12)

This is the fit of the model:

history=, validation_data=valid_ds, batch_size=100, epochs=10)

BTW i leave here the link to the code.

your real data could be your test split with the labels
the predicted data is what your trained model returns when you give the test split data.

is that it or maybe I didn’t understand the question

Yes but how do i extract from my Real data and the predicted Just de labeled 0,1 arrays. I do now know how to split the datasets in x_train and y_train.

I have tried with train_test_split but i cant.