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 = tf.data.Dataset.from_tensor_slices((arraynegativos, arrayceros))
ds_positives_target = tf.data.Dataset.from_tensor_slices((arraypositivos, 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= model.fit(train_ds, validation_data=valid_ds, batch_size=100, epochs=10)

BTW i leave here the link to the code.
  
      

      colab.research.google.com
  

  
    

Google Colaboratory