import numpy as np
import svm


# Size of vocabulary
voca = 0
with open("../data/vocabularyNN.txt",'r') as f:
	for line in f:
		voca += 1

# Load training data and label
data = np.loadtxt("../data/dataNN.txt", delimiter=' ', dtype=int)
label = np.loadtxt("../data/labelNN.txt", delimiter=' ', dtype=int)

folds = 11
predictAccCV = []

for k in range(2,folds+1):
	predictAcc = svm.svmCV(voca, data, label, k)
	predictAccCV.append(predictAcc)
	print predictAcc

accuracy = np.array(predictAccCV)
np.save('accNNsvm.npy', accuracy)

import numpy as np
import svm

# Size of vocabulary
voca = 0
with open("../data/vocabulary.txt", 'r') as f:
    for line in f:
        voca += 1

# Load training data and label
data = np.loadtxt("../data/data.txt", delimiter=' ', dtype=int)
label = np.loadtxt("../data/label.txt", delimiter=' ', dtype=int)

folds = 2
predictAccCV = []

for k in range(2, folds + 1):
    predictAcc = svm.svmCV(voca, data, label, k)
    predictAccCV.append(predictAcc)
    print predictAcc

accuracy = np.array(predictAccCV)
np.save('accAllsvm.npy', accuracy)
import numpy as np
import svm


filetype = 'Adj'
# filetype = 'NN'
# filetype = 'AllWords'
groups = 5

folds = 2
C = [1,10,100,1000]
kernel = ['linear','poly','rbf']
predictAccCV = np.zeros([4,3,folds])


for i,cp in enumerate(C):
	for j,ke in enumerate(kernel):
		print 'C:',cp
		print 'kernel:',ke				
		predictAccCV[i,j] = svm.svmCV(folds, filetype, groups, cp, ke)
		print 'predictAccCV:',predictAccCV

np.save('accSVM'+filetype+'.npy', predictAccCV)