How to initialize y_true and y_pred for confusion_matrix and classification_report? I have used flow_from_dataframe.
My code is as below:
train_set = train_datagen.flow_from_dataframe(
train,
path,
x_col="image_name",
y_col="level",
class_mode="raw",
color_mode="rgb",
batch_size=32,
target_size=(64, 64))
val_set = val_datagen.flow_from_dataframe(
val,
path,
x_col="image_name",
y_col="level",
class_mode="raw",
color_mode="rgb",
batch_size=32,
target_size=(64, 64))
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
Y_pred = model.predict(val_set)
y_pred = np.argmax(Y_pred, axis=1)
print('Confusion Matrix')
print(confusion_matrix(val_set.classes, y_pred))
print('Classification Report')
class_labels = list(val_set.class_indices.keys())
print(classification_report(val_set.classes, y_pred, target_names=class_labels))
I get the error as AttributeError: 'DataFrameIterator' object has no attribute 'classes'.
I am trying it since a ling time. I get result for flow_from_directory but not for flow_from_dataframe.
Please guide me.