Reputation: 11
I made a simple CNN and to allocate datasets I used image_dataset_from_directory() func
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
data_dir,
validation_split=0.2,
subset="training",
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)
val_ds = tf.keras.preprocessing.image_dataset_from_directory(
data_dir,
validation_split=0.2,
subset="validation",
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)
test_ds = tf.keras.preprocessing.image_dataset_from_directory(
check_dir,
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)
Now I was interested to create graphs like RocCurve and confusion_matrix, but I can't understand what should I put as an input?
Upvotes: 0
Views: 1122
Reputation: 11
I found the solution, if someone will face this problem
If you create cycle
for x, y in test_ds:
...
# Code
...
x - numpy array of images y - numpy array of true labels
UPD:
predictions = np.array([])
labels = np.array([])
scores = np.array([])
////////////
for x, y in test_ds:
predictions = np.concatenate([predictions, np.argmax(new_model.predict(x), axis=1)])
labels = np.concatenate([labels, y.numpy()])
scores = np.concatenate([scores, new_model.predict(x)[:, 1]])
Upvotes: 1
Reputation: 11
Depends basically on what you want and what do you use to create it.
For example to create a confusion matrix you can use the confusion_matrix
functions provided by sklearn (link here). In this case the function want as input the true label and the predicted label
Upvotes: 0