I keep getting the same error during knn analysis of a 1-dimensional data set. The function is presented below:
def KNN(data,legend):
importr('class') #package for knn object
print data #both DataFrame objects
print legend
KNN_result=robjects.r('knn')(data,data,legend,1) #k=1
The output as follows (firstly: data):
attribute
1 0
2 0
3 1
...
1635 0
1636 1
And now the legend:
[1] A A A A B B B B
...
[1633] A A A A
Levels: A B
The error:
Error in function (train, test, cl, k = 1, l = 0, prob = FALSE, use.all = TRUE) :
too many ties in knn
Can anybody please help ? Importantly -if the data are not binary, but range from 0 to 1 as float numbers the error does not appear and i can analyze the data correctly.