what is nn.index mean in KNN output I am getting attr(, "nn.index") as part of my KNN output in R. What is meant by that and how is this value getting calculated?

knn.pred &lt;- knn(tdm.stack.nl_train, tdm.stack.nl_Test, tdm.cand_train)
print(knn.pred)

&gt; knn.pred


[1] Silent      Silent      Silent      Silent      Silent      Silent      Silent     
 [8] Silent      Silent      Silent    


attr(,"nn.index")


      [,1]
[1,]  292  
[2,]  292  
[3,]  343  
[4,]  444  
[5,]  250  
[6,]  445  
[7,]  270  
[8,]  228  
[9,]  302  
[10,]  355
I guess you are using the fnn package.

attr is a list of attributes which can be used for both nn.index and nn.dist. In this case, you are using index.

So, index returns an n x k matrix for the nearest neighbor indice.

And the definition of the nearest neighbor index is:


  The nearest neighbor index is expressed as the ratio of the observed
  distance divided by the expected distance.


Definition reference