Commit fe73496e authored by Ngocson's avatar Ngocson

Saving the figure* correcting error

parent 89b14f64
......@@ -17,7 +17,7 @@ MNISTtestData = genfromtxt('DATA/MNISTtestData.csv', delimiter=',')
MNISTtestLabel = genfromtxt('DATA/MNISTtestLabel.csv', delimiter=',')
print("MNIST: loaded")
N = 81
N = 9
def scoreKmeansOverN(trainData,trainLabel,testData,testLabel,N):
......@@ -31,7 +31,7 @@ def scoreKmeansOverN(trainData,trainLabel,testData,testLabel,N):
pred = clf.predict(trainData)
for c,l in zip(pred,trainLabel.astype(np.int)):
cluster[c][l] += 1
cluster[c][l-3] += 1
for c in cluster:
score[0] += np.max(c)
......@@ -40,7 +40,7 @@ def scoreKmeansOverN(trainData,trainLabel,testData,testLabel,N):
cluster = np.zeros((n,len(np.unique(testLabel))))
pred = clf.predict(testData)
for c,l in zip(pred,testLabel.astype(np.int)):
cluster[c][l] += 1
cluster[c][l-3] += 1
for c in cluster:
score[1] += np.max(c)
......@@ -53,12 +53,13 @@ def scoreKmeansOverN(trainData,trainLabel,testData,testLabel,N):
sc = np.array(scoreKmeansOverN(MNISTtrainData,
MNISTtrainLabel,
MNISTtestData,
MNISTtrainLabel,
MNISTtestLabel,
N))
tr_score = sc[:,0]
te_score = sc[:,1]
fig, ax = plt.figure('Kmean over MNIST')
plt.figure('Kmean over WINE')
fig, ax = plt.subplots()
plt.plot(range(1,N),tr_score,'b.-',label='training score')
plt.plot(range(1,N),te_score,'r.-',label='testing score')
legend = ax.legend(loc=(0.8,0.1), shadow=True, fontsize='x-large')
plt.savefig("RESULT/kmeanOverMNIST.png")
\ No newline at end of file
legend = ax.legend(loc=(0.6,0.1), shadow=True)
plt.savefig("RESULTS/kmeanOverWINE.png")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment