featNo = chosenFeatures[j]
			file.write(str(j+1)+":")
			file.write(str(matrix[i][featNo])+" ")
		file.write("\n")
	return 0


result = loadPredict('predictions')
[labelEval, searchID] = loadTest('test.dat')
# print predict
# print labels
# print ids


ourRank = []
results = hh.splitColumnsForEachID(searchID, result)
labels = hh.splitColumnsForEachID(searchID, labelEval)


for i in range(len(results)):
	rank = []
	for j in range(len(results[i])):
		rank.append((results[i][j], labels[i][j]))
	rank = sorted(rank, key=itemgetter(0))
	ourRank.append(rank)

# for each in ourRank:
# 	for eeach in each:
# 		print eeach
# 	print "\n"
	
		time = (time.split())[0]
		month = int(time[5:7])
		day = int(time[-11:-9])
		dictMonth = {1:31,2:59,3:90,4:120,5:151,6:181,7:212,8:243,9:273,10:304,11:334,12:365}
		num_week = (dictMonth[month] + day+ int(booking[i]) )
		if num_week>=365:
			num_week = num_week%365
		num_week = num_week//7
		if num_week > 51:
			num_week = num_week%51
		allData[i][1] = num_week

	#24 normalizing distance 
	dis = hh.replaceNullwithMedian(allData,25)
	dis = hh.getColumn(allData,25)
	dis = hh.splitColumnsForEachID(searchIDs, dis)

	for i in range(len(dis)):
		dis[i] = hh.normalizeOneZeroVec(dis[i])
	normDis = []
	for each in dis:
		normEach = [i for i in each]
		normDis += normEach
	allData = hh.setColumn(allData,normDis,25)

	#p27-50 - remove Nulls (24 features)


	toFillNull = [4,5,13,18,19,20,21,22,24]
	for i in toFillNull:
		allData = hh.replaceNullwithMedian(allData,i)