ium_464913/metrics.py
2024-05-04 15:54:55 +02:00

23 lines
545 B
Python

from sklearn.metrics import confusion_matrix
import pandas as pd
def main():
y_test = pd.read_csv("data/y_test.csv")
y_pred = pd.read_csv("evaluation/y_pred.csv", header=None)
cm = confusion_matrix(y_test, y_pred)
print(
"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:
f.write(f"Accuracy: {accuracy}\n")
f.write(f"\n")
if __name__ == "__main__":
main()