forked from andbra16/CSF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomeWork.txt
26 lines (21 loc) · 814 Bytes
/
homeWork.txt
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
Problem 4 in Homework 7 (Optimized Version)
def average_error(state_edges_predicted, state_edges_actual):
"""
Given predicted state edges and actual state edges, returns
the average error of the prediction.
"""
count=0
error=0
averageError=0
# takes the dictionary of predicted and the dictionary of edges and
# checks if they are the same state. If they are the count increments
# and the error is calculated. After all the states are checked the average
# error is computed.
for i in state_edges_predicted:
if i in state_edges_actual:
count=count+1
tempError=abs(state_edges_predicted[i]-state_edges_actual[i])
error=error+tempError
if count>0:
averageError=error/count
return averageError