def knn(inx,labels,dataSet,k):
org_1Mat=np.tile(inx,(dataSet.shape[0],1))-dataSet
org_2Mat=org_1Mat**2
org_3Mat=org_2Mat.sum(axis=1)
org_4Mat=org_3Mat**0.5
distance=org_4Mat.argsort()
dataLabels={}
for i in range(k):
dataLabels[labels[distance[i]]]=dataLabels.get(labels[distance[i]],0)+1
return sorted(dataLabels.items(),key=operator.itemgetter(1),reverse=True)[0][0]