diff --git a/accent_classification/__pycache__/output_confusion_matrix.cpython-36.pyc b/accent_classification/__pycache__/output_confusion_matrix.cpython-36.pyc new file mode 100644 index 0000000..e852733 Binary files /dev/null and b/accent_classification/__pycache__/output_confusion_matrix.cpython-36.pyc differ diff --git a/accent_classification/output_confusion_matrix.py b/accent_classification/output_confusion_matrix.py index ae92fb2..5dfe2b8 100644 --- a/accent_classification/output_confusion_matrix.py +++ b/accent_classification/output_confusion_matrix.py @@ -9,14 +9,6 @@ from sklearn.metrics import accuracy_score 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, normalize=False, title='Confusion matrix', @@ -56,24 +48,32 @@ def plot_confusion_matrix(cm, classes, 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) -#print('accuracy: {}%'.format(accuracy * 100)) + regionLabels = ['Groningen_and_Drenthe', 'Oost_Overijsel-Gelderland', 'Limburg'] + regionLabels2 = ['Groningen_and_Drenthe', 'Limburg'] + dirOut = currDir + '\\result\\same-utterance_with_cities' -# confusion matrix -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) + pred = np.load(dirOut + '\\pred_per_pid_3regions.npy') -np.set_printoptions(precision=2) + #accuracy = accuracy_score(pred[:, 1], pred[:, 2], normalize=True, sample_weight=None) + #print('accuracy: {}%'.format(accuracy * 100)) -plt.figure() -plot_confusion_matrix(cm, classes=['GD', 'OG', 'LB'], normalize=True) -#plot_confusion_matrix(cm, classes=['GD', 'LB'], normalize=True) + # confusion matrix + 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) -#plt.show() -plt.savefig(dirOut + '\\cm_machine_3regions_normalized.png') \ No newline at end of file + np.set_printoptions(precision=2) + + 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') \ No newline at end of file