Apr-18-2023, 03:53 PM
hi, I have tried my best to output the confusion matrix. but it didn't work either. I don't know what coding can produce the output for the confusion matrix.
def print_confusion_matrix(y_true, y_pred):
cm = confusion_matrix(y_true, y_pred)
print('True positive = ', cm[0][0])
print('False positive = ', cm[0][1])
print('False negative = ', cm[1][0])
print('True negative = ', cm[1][1])
print('\n')
df_cm = pd.DataFrame(cm, range(2), range(2))
sn.set(font_scale=1.4) # for label size
sn.heatmap(df_cm, annot=True, annot_kws={"size": 16}) # font size
plt.ylabel('Actual label', size = 20)
plt.xlabel('Predicted label', size = 20)
plt.xticks(np.arange(2), ['Fake', 'Real'], size = 16)
plt.yticks(np.arange(2), ['Fake', 'Real'], size = 16)
plt.ylim([2, 0])
plt.show()
predict_x=model.predict(X)
classes_x=np.argmax(predict_x,axis=1)
print(confusion_matrix)the output:Error:<function confusion_matrix at 0x7fb8e9bccca0>I just want my coding show from the attachment but don't get it. Any help I will appreciate. Thanks
