added scoring

This commit is contained in:
Tom Selier 2023-10-13 16:23:24 +02:00
parent 6feaab7f68
commit 9d7485caa8

View File

@ -6,7 +6,7 @@ import csv
from sklearn.preprocessing import MinMaxScaler from sklearn.preprocessing import MinMaxScaler
from enum import Enum from enum import Enum
import random import random
from sklearn.metrics import confusion_matrix from sklearn.metrics import confusion_matrix, accuracy_score, precision_score, recall_score
class Tree(Enum): class Tree(Enum):
ACCASIA = 0 ACCASIA = 0
@ -102,4 +102,11 @@ for validateId in range(0, tags_len - 1):
# Create a heatmap # Create a heatmap
sns.heatmap(confusion_matrix(tag_true, tag_predict), annot=True) sns.heatmap(confusion_matrix(tag_true, tag_predict), annot=True)
plt.title( "Confusion Matrix KNN" ) plt.title( "Confusion Matrix KNN" )
plt.show() 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'))