This commit is contained in:
Mateusz 2024-05-04 15:54:55 +02:00
parent a8cf8d2829
commit 9d6ffe8205
2 changed files with 8 additions and 10 deletions

View File

@ -1,8 +1,4 @@
from sklearn.metrics import ( from sklearn.metrics import confusion_matrix
accuracy_score,
precision_score,
recall_score,
)
import pandas as pd import pandas as pd
@ -10,14 +6,15 @@ def main():
y_test = pd.read_csv("data/y_test.csv") y_test = pd.read_csv("data/y_test.csv")
y_pred = pd.read_csv("evaluation/y_pred.csv", header=None) y_pred = pd.read_csv("evaluation/y_pred.csv", header=None)
accuracy = accuracy_score(y_test, y_pred) cm = confusion_matrix(y_test, y_pred)
precision_micro = precision_score(y_test, y_pred, average="micro") print(
recall_micro = recall_score(y_test, y_pred, average="micro") "Recall metric in the testing dataset: ",
cm[1, 1] / (cm[1, 0] + cm[1, 1]),
)
accuracy = cm[1, 1] / (cm[1, 0] + cm[1, 1])
with open(r"evaluation/metrics.txt", "a") as f: with open(r"evaluation/metrics.txt", "a") as f:
f.write(f"Accuracy: {accuracy}\n") f.write(f"Accuracy: {accuracy}\n")
f.write(f"Micro-average Precision: {precision_micro}\n")
f.write(f"Micro-average Recall: {recall_micro}\n")
f.write(f"\n") f.write(f"\n")

View File

@ -11,6 +11,7 @@ import numpy as np
def main(): def main():
model = load_model("model/model.keras") model = load_model("model/model.keras")
X_test = pd.read_csv("data/X_test.csv") X_test = pd.read_csv("data/X_test.csv")
y_test = pd.read_csv("data/y_test.csv")
y_pred = model.predict(X_test) y_pred = model.predict(X_test)
y_pred = y_pred >= 0.5 y_pred = y_pred >= 0.5