ium_444354/evaluation.py

30 lines
816 B
Python
Raw Normal View History

2022-05-03 22:47:51 +02:00
import pandas as pd
import re
from sklearn import metrics
import numpy as np
2022-05-07 04:46:30 +02:00
import csv
2022-05-03 22:47:51 +02:00
f = open("result.txt", "r")
list_result, list_predicted=[],[]
for x in f:
data = x.split(' ')
result = re.findall(r'\d+', data[1])
predicted = re.findall(r'\d+', data[5])
result=int(result[0])
predicted=float('.'.join(predicted))
list_result.append(result)
list_predicted.append(predicted)
2022-05-07 04:46:30 +02:00
metrics = metrics.mean_absolute_error(list_result, list_predicted), metrics.mean_squared_error(list_result, list_predicted),np.sqrt(metrics.mean_absolute_error(list_result, list_predicted))
print("MAE: ", metrics[0])
print("MSE: ",metrics[1])
print("RMSE: ",metrics[2])
with open('eval.csv', 'a', newline='') as f:
writer = csv.writer(f)
writer.writerow((metrics[0],metrics[1], metrics[2]))