Function that computes the classification accuracy
Parameters: |
-
params
–
the same parameters from the class
|
result_acc (float): the classification accuracy
result_std (float): the standard deviation of the classification
accuracy
Source code in src/desgld/evaluation.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 | def compute_accuracy(self):
"""Function that computes the classification accuracy
Args:
params: the same parameters from the class
Returns:
result_acc (float): the classification accuracy
result_std (float): the standard deviation of the classification
accuracy
"""
mis_class = np.empty((self.T + 1, len(self.history_all[0, 0, 0])))
for t in range(self.T + 1):
for n in range(len(self.history_all[t, 0, 0])):
temp0 = 0
for i in range(len(self.x_all)):
z = 1 / (
1
+ np.exp(
-np.dot(
np.transpose(self.history_all[t, 1])[n],
self.x_all[i],
)
)
)
if z >= 0.5:
z = 1
else:
z = 0
if self.y_all[i] != z:
temp0 += 1
mis_class[t, n] = 1 - temp0 / len(self.x_all)
result_acc = np.mean(mis_class, axis=1)
result_std = np.std(mis_class, axis=1)
return result_acc, result_std
|