I have doubts how value of y is deciding that the point belong of which class.
def knn(x,y,query_x,k=5):
vals=[]
m=x.shape[0]
for i in range(m):
d=dist(query_x,x[i])
vals.append((d,y[i]))
vals=sorted(vals)
vals=vals[:k]
vals=np.array(vals)
new_vals=np.unique(vals[:,1],return_counts=True)
index=new_vals[1].argmax()
pred=new_vals[0][index]