-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_dataset_results.py
55 lines (48 loc) · 2.02 KB
/
parse_dataset_results.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from GlobalUtils import *
dataset = 'B'; #'B', 'A'
processed = ''; #'', '_NP'
validation = '_loo';#'', '_loo'
file = 'dataset' + dataset + validation + processed + '.txt';
path = '/home/javedzahoor/research/mattia/code/jz/results'#'C:\Users\javed.zahoor\Dropbox\PhD\Research-2015-05-04\Research\Thesis III\Results';
fullName = path + '/' + file;
f = open(fullName, "r");
technique="";
accuracy="";
variance="";
FSSize=0;
timeTaken = 0;
classifier = '';
nextIsTime = False;
i=-1;
while True:
i = i+1;
v = f.readline();
if not v: break
if i==0:
save_to_db(dataset, file, FSSize, technique, classifier, validation.replace('_',"").upper() + 'CV', accuracy, variance, timeTaken);
#query = "insert into results(dataset, fileName, size, FStechnique, classifier, validationTechnique, accuracy, variance, timeTaken) values('"+dataset+"','"+file+"',"+str(FSSize)+",'"+technique+"','"+classifier+"','"+'"+validation.upper() + 'CV'+"'+"',"+accuracy+","+variance+", " + str(timeTaken) + ");";
if(FSSize>0):
print(query);
if(isInt(v.replace("\n",""))):
FSSize = v.replace("\n","");
if isFeatureSelector(v.replace("\n","")):
technique = v.replace("\n","");
if v.startswith('Accuracy'):
i=-1;
accuracy = v.replace("\n","");
accuracy = accuracy.replace('Accuracy: ',"");
accuracy = accuracy.replace('(',"");
accuracy = accuracy.replace(')',"");
#print(accuracy);
parts = accuracy.split('+/- ');
accuracy = parts[0];
#print(accuracy);
variance = parts[1];
#print(variance);
if isClassifier(v.replace("\n","")) or isEnsemble(v.replace("\n","")):
classifier = v.replace("\n","");
if isEnsemble(v.replace("\n","")): #ignore one line that says Training Ensemble
f.readline();
timeTaken = f.readline().replace("\n","").replace('It took:',"");
f.close();
print('done with reading the file...');