Ejemplo n.º 1
0
		max_index = -1
		candidate = []
		candidate_value = []
		for j in xrange(len(result[i])):
			if result[i][j] > 0.8:
				candidate.append(DataParser.label_index[j])
				candidate_value.append(result[i][j])
			if result[i][j] > max_value:
			    max_value = result[i][j]
			    max_index = j
		with open('candidate.txt', 'a') as cf:
			cf.write(DataParser.label_index[max_index] + ' of ' + str(candidate) + ': ' + str(candidate_value) + '\n')
		#f.write(random.choice(candidate) + '\n')
		f.write(DataParser.label_index[max_index] + '\n')

correct, all_record = DataParser.check('result.txt', label_file)
print 'correction rate: %i/ %i' %(correct, all_record)

solution_data, solution_id = DataParser.load_test_data(test_file)
solution = test(solution_data)
solution = list(solution)
solution = map(list, zip(*solution))  # transpose
with open('solution.csv', 'w') as f:
	f.write('Id,Prediction\n')
	for i in xrange(len(solution)):
		f.write(solution_id[i] + ',')
		max_value = 0
		max_index = -1
		for j in xrange(len(solution[i])):
			if solution[i][j] > max_value:
				max_value = solution[i][j]