From 9d7485caa882e88e9e66c89f63e5eceb0a145d1f Mon Sep 17 00:00:00 2001 From: Tom Selier Date: Fri, 13 Oct 2023 16:23:24 +0200 Subject: [PATCH] added scoring --- src/experiments/knn/knn.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/experiments/knn/knn.py b/src/experiments/knn/knn.py index c5d4617..d06d20d 100644 --- a/src/experiments/knn/knn.py +++ b/src/experiments/knn/knn.py @@ -6,7 +6,7 @@ import csv from sklearn.preprocessing import MinMaxScaler from enum import Enum import random -from sklearn.metrics import confusion_matrix +from sklearn.metrics import confusion_matrix, accuracy_score, precision_score, recall_score class Tree(Enum): ACCASIA = 0 @@ -102,4 +102,11 @@ for validateId in range(0, tags_len - 1): # Create a heatmap sns.heatmap(confusion_matrix(tag_true, tag_predict), annot=True) plt.title( "Confusion Matrix KNN" ) -plt.show() \ No newline at end of file +plt.show() + +# Score +print("Accuracy score", accuracy_score(tag_true, tag_predict)) +print("Precision score (macro)", precision_score(tag_true, tag_predict, average='macro')) +print("Precision score (micro)", precision_score(tag_true, tag_predict, average='micro')) +print("Recall score (macro)", recall_score(tag_true, tag_predict, average='macro')) +print("Recall score (micro)", recall_score(tag_true, tag_predict, average='micro')) \ No newline at end of file