output_confusion_matrix is changed to be a function.
This commit is contained in:
parent
edcbb1139a
commit
9baa0f8641
Binary file not shown.
@ -9,14 +9,6 @@ from sklearn.metrics import accuracy_score
|
|||||||
from sklearn.metrics import confusion_matrix
|
from sklearn.metrics import confusion_matrix
|
||||||
|
|
||||||
|
|
||||||
currDir = 'C:\\Users\\Aki\\source\\repos\\rug_VS\\dialect_identification\\dialect_identification'
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(sys.path[0]), currDir))
|
|
||||||
|
|
||||||
regionLabels = ['Groningen_and_Drenthe', 'Oost_Overijsel-Gelderland', 'Limburg']
|
|
||||||
regionLabels2 = ['Groningen_and_Drenthe', 'Limburg']
|
|
||||||
dirOut = currDir + '\\result\\same-utterance_with_cities'
|
|
||||||
|
|
||||||
|
|
||||||
def plot_confusion_matrix(cm, classes,
|
def plot_confusion_matrix(cm, classes,
|
||||||
normalize=False,
|
normalize=False,
|
||||||
title='Confusion matrix',
|
title='Confusion matrix',
|
||||||
@ -56,24 +48,32 @@ def plot_confusion_matrix(cm, classes,
|
|||||||
plt.xlabel('Predicted label', fontsize=_fontsize-4)
|
plt.xlabel('Predicted label', fontsize=_fontsize-4)
|
||||||
|
|
||||||
|
|
||||||
pred = np.load(dirOut + '\\pred_per_pid_3regions.npy')
|
if __name__ == "__main__":
|
||||||
|
currDir = 'C:\\Users\\Aki\\source\\repos\\rug_VS\\dialect_identification\\dialect_identification'
|
||||||
|
sys.path.append(os.path.join(os.path.dirname(sys.path[0]), currDir))
|
||||||
|
|
||||||
#accuracy = accuracy_score(pred[:, 1], pred[:, 2], normalize=True, sample_weight=None)
|
regionLabels = ['Groningen_and_Drenthe', 'Oost_Overijsel-Gelderland', 'Limburg']
|
||||||
#print('accuracy: {}%'.format(accuracy * 100))
|
regionLabels2 = ['Groningen_and_Drenthe', 'Limburg']
|
||||||
|
dirOut = currDir + '\\result\\same-utterance_with_cities'
|
||||||
|
|
||||||
# confusion matrix
|
pred = np.load(dirOut + '\\pred_per_pid_3regions.npy')
|
||||||
cm = confusion_matrix(pred[:, 1], pred[:, 2], labels=regionLabels)
|
|
||||||
# human perception (2 regions)
|
|
||||||
#cm = np.array([[39, 57], [6, 104]])
|
|
||||||
# human perception (3 regions)
|
|
||||||
#cm = np.array([[22, 14, 52], [23, 21, 52], [5, 5, 100]])
|
|
||||||
print(cm)
|
|
||||||
|
|
||||||
np.set_printoptions(precision=2)
|
#accuracy = accuracy_score(pred[:, 1], pred[:, 2], normalize=True, sample_weight=None)
|
||||||
|
#print('accuracy: {}%'.format(accuracy * 100))
|
||||||
|
|
||||||
plt.figure()
|
# confusion matrix
|
||||||
plot_confusion_matrix(cm, classes=['GD', 'OG', 'LB'], normalize=True)
|
cm = confusion_matrix(pred[:, 1], pred[:, 2], labels=regionLabels)
|
||||||
#plot_confusion_matrix(cm, classes=['GD', 'LB'], normalize=True)
|
# human perception (2 regions)
|
||||||
|
#cm = np.array([[39, 57], [6, 104]])
|
||||||
|
# human perception (3 regions)
|
||||||
|
#cm = np.array([[22, 14, 52], [23, 21, 52], [5, 5, 100]])
|
||||||
|
print(cm)
|
||||||
|
|
||||||
#plt.show()
|
np.set_printoptions(precision=2)
|
||||||
plt.savefig(dirOut + '\\cm_machine_3regions_normalized.png')
|
|
||||||
|
plt.figure()
|
||||||
|
plot_confusion_matrix(cm, classes=['GD', 'OG', 'LB'], normalize=True)
|
||||||
|
#plot_confusion_matrix(cm, classes=['GD', 'LB'], normalize=True)
|
||||||
|
|
||||||
|
#plt.show()
|
||||||
|
plt.savefig(dirOut + '\\cm_machine_3regions_normalized.png')
|
Loading…
Reference in New Issue
Block a user