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 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
@ -103,3 +103,10 @@ for validateId in range(0, tags_len - 1):
sns.heatmap(confusion_matrix(tag_true, tag_predict), annot=True)
plt.title( "Confusion Matrix KNN" )
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'))