forked from rajatkuls/lena-clean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrap-e-subpr.py
43 lines (30 loc) · 1020 Bytes
/
wrap-e-subpr.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
import numpy as np
import os
import glob
import cPickle as pickle
from sklearn.metrics import classification_report
from sklearn.metrics import f1_score
from sklearn.metrics import precision_score
from sklearn.metrics import recall_score
import extractFeatures
import sys
true_stm = sys.argv[1]
output_vec = sys.argv[2]
y_true = extractFeatures.getLabelPerWav(true_stm,extractFeatures.stStep,extractFeatures.classMapTernaryFn,extractFeatures.shortSpeechDict)
y_pred = pickle.load(open(output_vec,'r'))
if len(y_pred)<len(y_true):
y_true = y_true[:len(y_pred)]
if len(y_true)<len(y_pred):
y_pred = y_pred[:len(y_true)]
x = true_stm[true_stm.rfind('/')+1:]
outfile = x[:x.rfind('.')]
f = open('hyp/avg/'+outfile,'w')
f.write('F1\n')
f.write(str(f1_score(y_true,y_pred,average='weighted')))
f.write('\n')
f.write('Precision\n')
f.write(str(precision_score(y_true,y_pred,average='weighted')))
f.write('\n')
f.write('Recall\n')
f.write(str(recall_score(y_true,y_pred,average='weighted')))
f.write('\n')