如何用 Keras 制作混淆矩阵?

Itr*_*tra 1 python machine-learning confusion-matrix keras tensorflow

我已经使用 keras 训练了 CNN 模型(多类分类),现在我想在我的测试图像集上评估该模型。有没有办法创建混淆矩阵?

Itr*_*tra 6

感谢您的回答。我确实是这样的:

#Predict
y_prediction = model.predict(x_test)
y_prediction = np.argmax (y_prediction, axis = 1)
y_test=np.argmax(y_test, axis=1)
#Create confusion matrix and normalizes it over predicted (columns)
result = confusion_matrix(y_test, y_prediction , normalize='pred')
print(result)
Run Code Online (Sandbox Code Playgroud)