トレーニング データの 6 つの異なる値に対して 6 つの異なる混同行列を生成しています。生成された混同行列を画像として保存しようとしています。残念ながら、保存するとき、空の jpeg 画像として保存し続けます。ただし、show() を使用して表示すると、表示されます。これが私のコードです
for matrix in confusion_matrices:
fig = plt.figure()
plt.matshow(cm)
plt.title('Problem 1: Confusion Matrix Digit Recognition')
plt.colorbar()
plt.ylabel('True Label')
plt.xlabel('Predicated Label')
fig.savefig('confusion_matrix'+str(learning_values.pop())+'.jpg')
次のライブラリを使用しています。
import matplotlib.pyplot as plt
import numpy
from numpy import ravel, reshape, swapaxes
import scipy.io
from sklearn import svm
from sklearn.metrics import confusion_matrix
from random import sample
混同行列を効率的に保存するにはどうすればよいですか?