Comments (2)
Hi Cornel,
Thanks for the bug report. As you say the present situation is not ideal, but I am not sure of the right approach to take. The explanation for the current behaviour is that it is determined entirely by the underlying libnabo. The authors of that package have decided not to use a dedicated value to signal an invalid index in the results (see this issue.), instead returning 0, which the knn function then returns as 1 (because we use R-style 1-indexing rather than C style 0-indexing).
Using your example code above, if we look at the result we can still see that there is information in the result to indicate that something is not right:
> knn(targets, query, k=1)
$nn.idx
[,1]
[1,] 1
[2,] 1
[3,] 3
$nn.dists
[,1]
[1,] Inf
[2,] Inf
[3,] 0
So the value of nn.dists is Inf
when there is no valid match. It would be possible to convert nn.idx to NA
for non-finite nn.dists.
As a minimum the present behaviour for inputs containing NA
values should be documented. Best,
Greg.
from nabor.
Hi Greg,
Thanks for replying so quickly and for clarifying this issue. Given your explanation, I think it's probably not a good idea to modify the underlying behaviour, since that'd be the responsibility of the libnabo developers. That said, it may be useful to have an extra (optional) argument in knn to request conversion of indices to NA? On the other hand, such argument may be deprecated in the future potentially causing some minor headaches (I still consider this issue to be a bug in, not a feature of, libnabo).
Documenting NA handling would probably be sufficient, since it's easy enough to clean the output, or the input before passing it to knn.
Cheers,
Cornel
from nabor.
Related Issues (10)
- Make WKNN a templated class
- ask for your help about your "nabor" package HOT 2
- Trouble installing nabor HOT 2
- UBSAN issue when libnabo calculates maxNodeCount HOT 1
- CRAN version Install fails on Ubuntu 16.04 HOT 1
- Fix warning related to registration of native routines HOT 4
- No radius search HOT 2
- loading of package fails HOT 4
- remove register keyword from libnabo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nabor.