-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval_Step2.py
executable file
·49 lines (42 loc) · 1.01 KB
/
eval_Step2.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
#!/usr/bin/env python3
# coding: utf-8
#//Autors : Quentin Clayssen, Antoine Laine (Master2 Bioinformatics, University of Nantes)
#//Seconde evalution of Naive result
#//Created :09/11/18
#//Modified :11/02/2019
import re
import os
import random
import math
import sys
import warnings
Folder=sys.argv[1]
filename=sys.argv[2]
TP=0
FN=0
FP=0
nb_runs=1
with open(os.path.join(Folder, filename), 'r') as results:
ligne=results.readline()
while ligne:
if ligne.strip()=="TP":
TP+=1
elif ligne.strip()=="FP":
FP+=1
else:
FN+=1
nb_runs+=1
ligne=results.readline()
if TP==0:
recall=0
precision=0
fmeasure=0
power=0
else:
recall = TP/(TP+FN)
precision = TP/(TP+FP)
fmeasure=2/(1/recall+1/precision)
power = TP/nb_runs
powerRes=open(os.path.join(Folder, "power_"+filename),'w')
powerRes.write("Recall="+str(recall)+'\n'+"Precision="+str(precision)+'\n'+"F-measure="+str(fmeasure)+'\n'+"Power="+str(power))
powerRes.close()