-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSharedFunctions.py
More file actions
30 lines (23 loc) · 789 Bytes
/
SharedFunctions.py
File metadata and controls
30 lines (23 loc) · 789 Bytes
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
from ReadPreprocessData import HAM, SPAM
import time
fmt = '%H:%M:%S'
def get_current_time():
time.ctime()
return time.strftime(fmt)
def find_accuracy(predicted_labels, actual_labels):
accuracy = 0
wrong_ham = 0
wrong_spam = 0
i = 0
l = len(actual_labels)
while i < l:
if actual_labels[i] == predicted_labels[i]:
accuracy += 1
elif actual_labels[i] == HAM:
wrong_ham += 1
else:
wrong_spam += 1
i += 1
print("Accurately Identified:", accuracy, "Percentage:", accuracy * 100 / l)
print("Wrongly Identified Legitimate as Spam:", wrong_ham, "Percentage:", wrong_ham * 100 / l)
print("Wrongly Identified Spam as Legitimate:", wrong_spam, "Percentage:", wrong_spam * 100 / l)