-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (30 loc) · 925 Bytes
/
main.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 sklearn_crfsuite
from crfsuite import CRFSuite
import utils
from sffs import SFFS
#import classifiers
train_dataset = open('datasets/dev_feats_3.5-train','r')
test_dataset = open('datasets/dev_feats_3.5-test','r')
X_train,y_train = utils.extractFeatures(train_dataset)
dim_train = utils.extractDim(X_train)
X_test, y_test = utils.extractFeatures(test_dataset)
#Binary token in one step
#y_train = utils.binary_label_transform(y_train)
#y_test = utils.binary_label_transform(y_test)
crf = CRFSuite('l2sgd')
sffs = SFFS(crf,X_train,y_train,X_test,y_test,dim_train)
sffs = sffs.fit()
'''
#save last model
crf = sffs.classifier
pred = sffs.y_pred
del sffs
#add first step input
for prediction,vector in zip(y_pred,X_test):
for t,y in enumerate(prediction):
vector.append(crf.tagger_.marginal(y,t))
#change sffs
sffs = SFFS(crf,X_test,y_test,X_train,y_test,dim_train)
sffs = sffs.fit()
'''
#utils.getMetrics()