-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTester.py
37 lines (28 loc) · 1.08 KB
/
Tester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from Evaluator import Evaluator
import pandas
import numpy as np
from sklearn.metrics import mean_squared_error as rmse
from sklearn.metrics import r2_score as r_2
from sklearn.metrics import median_absolute_error as medae
from sklearn.metrics import mean_absolute_error as mae
class Tester:
def __init__(self, bound) -> None:
self.__bound = bound
self.__evaluator = Evaluator()
def test(self, test_set, program):
# print('***********Testing**************')
program.resetHits()
expected = []
predicted = []
for i, row in test_set.iterrows():
expected.append(row['Duration'])
predicted.append(round(self.__evaluator.evaluate(program, row),1))
return (predicted, expected)
def RMSE(self, predicted, expected):
return rmse(expected, predicted)
def R_Squared(self, predicted, expected):
return r_2(expected, predicted)
def MedAE(self, predicted, expected):
return medae(expected, predicted)
def MAE(self, predicted, expected):
return mae(expected, predicted)