如何使用混淆矩阵可视化预测样本

问题描述 投票:0回答:1

我想问如何可视化用于测试使用混淆矩阵创建的模型的样本,例如如下。 enter image description here

这是我的代码

火车模型

epochs = 10

mc = ModelCheckpoint('sequential', monitor='val_accuracy', mode='max', verbose=1, save_best_only=True)  
early_stopping = EarlyStopping(monitor='val_loss', patience=2)
history=model.fit(x=train_gen, epochs=epochs, validation_data=valid_gen)

混淆矩阵

print_code=0
preds=model.predict(test_gen) 
print_info( test_gen, preds, print_code, save_dir, subject ) 

输出 enter image description here

我不仅想显示表输出和召回率、精度和 f1 得分值,还想显示 CM 预测的每个图像的可视化,也许像上面的图像一样,或者可能会更好。

例如,在“Daun Sehat”表中,有一个数据样本被预测为“Karat Merah”,但如果没有可视化,我不知道“Daun Sehat”的哪个图像样本被检测为“Karat Merah”该信息

我希望有人可以帮助我,因为我还是新手,正在学习

python scikit-learn deep-learning confusion-matrix image-classification
1个回答
0
投票

目前还不清楚如何绘制混淆矩阵,但您可以迭代

preds
test_gen
并在标签不同时绘制样本和输出。

由于您没有显示模型使用的输入类型,因此要使用的显示方法取决于您。

© www.soinside.com 2019 - 2024. All rights reserved.