ium_444354/evaluation.py
Adrian Charkiewicz 97681d967d
Some checks failed
s444354-training/pipeline/head There was a failure building this commit
evaluation appends to csv
2022-05-07 04:46:30 +02:00

30 lines
816 B
Python

import pandas as pd
import re
from sklearn import metrics
import numpy as np
import csv
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)
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]))