def testSVM(): ## loading data log = "Step 1: loading data..." writeLog(log) print log test_x, test_y = loadDigitTestData() # scales from -1 to 1 test_x = test_x/255.0*2 - 1 # initialize the vote matrix for testing data, Votes[m, 10] m, dump = shape(test_y) Votes = mat(zeros((m, 10))) ## testing data log = "Step 2: testing data..." for i in range(10): for j in range(i+1, 10): log = "--working on model: " + str(i) + '&' + str(j) print log writeLog(log) # loading the models d = shelve.open('./models/svm_' + str(i) + '_' + str(j)) svmClassifier = d['svm'] d.close() # testing using the given model and votes Votes_k, Votes_l = SVM.testDigitScores(svmClassifier, test_x, m) # write to the Votes Votes[:, i] += Votes_k Votes[:, j] += Votes_l ## saving Votes matrix log = "Step 3: saving votes..." print log writeLog(log) d = shelve.open('./models/Votes_Score_noscale') d['vote'] = Votes d.close()