Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Off by one error with $Knn_Query() #5

Closed
jefferys opened this issue Mar 7, 2020 · 4 comments
Closed

Off by one error with $Knn_Query() #5

jefferys opened this issue Mar 7, 2020 · 4 comments
Labels

Comments

@jefferys
Copy link

jefferys commented Mar 7, 2020

Using nmslibR_1.0.3, I'm getting an off by one error in the returned index of the similar row from $KnnQuery().

> x <- rbind( c(1,1,1,1), c(2,2,2,2), c(1,1,50,50), c(2,2,51,51), c(1,2,1,2), c(1,2,51,50) )
> x
     [,1] [,2] [,3] [,4]
[1,]    1    1    1    1
[2,]    2    2    2    2
[3,]    1    1   50   50
[4,]    2    2   51   51
[5,]    1    2    1    2
[6,]    1    2   51   50

> dataBase <- NMSlib$new( x, method= "hnsw", space= "l2" )
> dataBase$Knn_Query( x[1,], k= 1 )
> result
[[1]]
[1] 4

[[2]]
[1] 1.414214

> x[4,]
[1]  2  2 51 51
@mlampros
Copy link
Owner

mlampros commented Mar 7, 2020

hi @jefferys,
thanks for making me aware of the this issue. It was a difference in indexing between R and Python. I fixed it, you can download the updated version using

remotes::install_github(repo = 'mlampros/nmslibR')

@jefferys
Copy link
Author

jefferys commented Mar 8, 2020

Thanks; looks like this is fixed now. Also, for the historical record, wanted to point out that this did not affect the $knn_Query_Batch() function; that was and is returning the correct indexes.

@mlampros
Copy link
Owner

mlampros commented Mar 8, 2020

The Knn_Query() and the knn_Query_Batch() are two different methods of the NMSlib R6 class. Although, I took into account the difference in indexing in the knn_Query_Batch() method I omitted to do the same for the Knn_Query() method. Thanks again for spotting this issue.

@stale
Copy link

stale bot commented Mar 20, 2020

This is Robo-lampros because the Human-lampros is lazy. This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs. Feel free to re-open a closed issue and the Human-lampros will respond.

@stale stale bot added the stale label Mar 20, 2020
@stale stale bot closed this as completed Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants