-
Notifications
You must be signed in to change notification settings - Fork 0
/
calcAccuracy.py
31 lines (23 loc) · 906 Bytes
/
calcAccuracy.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
#!/usr/bin/python
"""
This script is used to calculate the accuracy of Tesseract
You need to run downloadCaptchas.py first
"""
import os
__author__ = 'smartjinyu'
savingDir = '../trainData'
def calcAccuracy():
total = 0
for root, dir, files in os.walk(savingDir):
total += len(files)
rawData = len([name for name in os.listdir(savingDir + '/rawData')]) + len(
[name for name in os.listdir(savingDir + '/processed')])
negative = len([name for name in os.listdir(savingDir + '/failures')])
positive = (total - rawData - negative) / 4
accuracy = positive / (positive + negative)
print('Accuracy = {} / {} = {:.7f}'.format(positive, positive + negative, accuracy))
return accuracy
if __name__ == '__main__':
print('This script is used to calculate the accuracy of Tesseract')
print('You need to run downloadCaptchas.py first')
calcAccuracy()