I’d like to announce Neighborhood.jl, a new Julia package that has the following purpose: Provide a unified API for finding nearest (or approximately nearest) neighbors in Julia. The API is exceptionally simple (documentation):
- Initialize the search structure by calling
ss = searchstructure(TheTypeToUse, data, metric)
. - Use it for making searches with
search(ss, query, searchtype, ...; ...)
-
searchtype
is one of two types:WithinRange(::Real)
andNeighborNumber(::k)
. Shorthands tosearch
withinrange
andknn
are provided. - Other methods that may (or may not) offer performance benefits depending on the type of
ss
are also provided.
The idea for this started in a previews post about VPTrees.jl, see here if interested. Me, @altre , @JonasIsensee and @zgornel were talking about making a unified interface.
Progress on this has been extremely slow, but I grew tired of constantly re-inventing the wheel at JuliaDynamics and constantly re-writing interfaces for NearestNeighbors.jl so Neighborhood.jl was published.
I documented the package as well as I could, and there is an example interfacing of KDTrees, with every single method being (to the best of my knowledge) the most performant possible. It is only my hope now that the community will feel compelled to interface more packages into Neighborhood.jl
Having many packages in Neighborhood.jl is exceptionally useful for the scientific community. @JonasIsensee has done a small project where he has measured different packages and how they perform, and depending on the dimensionality of your data, how they are structured in their state space, how many searches you want, and how many searches you need to do in bulk, and whether you need filtering, it is not obvious which packages should be the fastest for your application. Neighborhood.jl allows you to immediately and trivially swap a nearest neighbor finding package in your algorithm by changing a single argument: TheTypeToUse
(which could be KDTree
, VPTree
, etc.).
If you would like to contribute, that would be amazing. This issue lists packages that offer nearest (or approximately nearest) neighbor searching in Julia, and would be great to interface any of them. I’ve added a “Dev Docs” page in the documentation to make this easy.