source: internals/2016/aptoideimagesdetector/trunk/explicit_content_detector/API/Explicit_detector/API to download database/misclassified_apps.py @ 16448

Last change on this file since 16448 was 16448, checked in by dferreira, 3 years ago

File organization totally changed

File size: 1.3 KB
Line 
1# Aptoide, 2016
2# Diogo Ferreira
3# This script gets the percentage of misclassified apps (text or image explicit) on a database.
4
5
6from __future__ import division
7import os
8import glob
9import sqlite3
10
11def is_explicit(id_int):
12
13        types = [".jpg", ".png"]
14
15        os.chdir("./Big_Database/images/icons_explicit")
16       
17        for type_image in types:
18                for image in glob.glob(str(id_int)+"*"+type_image):
19                    os.chdir("../../..")
20                    return True
21       
22
23        os.chdir("../screenshot_explicit")
24        for type_image in types:
25                for image in glob.glob(str(id_int)+"*"+type_image):
26                    os.chdir("../../..")
27                    return True
28
29        os.chdir("../../..")
30
31        return False
32
33
34db = sqlite3.connect('app_info_big.db')
35
36c = db.cursor()
37
38tp=0
39fp=0
40tn=0
41fn=0
42
43
44c.execute(''' SELECT age,id FROM app_data WHERE mature=1''')
45
46for d in c.fetchall():
47        if d[0]==18 or is_explicit(d[1]):
48                tp+=1
49        else:
50                fn+=1
51
52c.execute(''' SELECT age,id FROM app_data WHERE mature=0''')
53
54for d in c.fetchall():
55        if d[0]==18 or is_explicit(d[1]):
56                fp+=1
57        else:
58                tn+=1
59
60
61
62db.close()
63
64pr = tp/(tp+fp)
65rec = tp/(tp+fn)
66fsc = 2*(pr*rec)/(pr+rec)
67acc = ((tp+tn)/(fp+fn+tn+tp))*100
68
69print "True Positives: "+str(tp)
70print "False Positives: "+str(fp)
71print "True Negatives: "+str(tn)
72print "False Negatives: "+str(fn)
73print "Precision: "+str(pr)
74print "Recall: "+str(rec)
75print "F-Score: "+str(fsc)
76print "Accuracy Percent: "+str(acc)
77
Note: See TracBrowser for help on using the repository browser.