https://github.com/petabi/petal-neighbors
Nearest neighbor search algorithms including a ball tree and a vantage point tree.
https://github.com/petabi/petal-neighbors
ball-tree knn nearest-neighbor-search vantage-point-tree
Last synced: 5 months ago
JSON representation
Nearest neighbor search algorithms including a ball tree and a vantage point tree.
- Host: GitHub
- URL: https://github.com/petabi/petal-neighbors
- Owner: petabi
- License: apache-2.0
- Created: 2019-06-05T02:46:54.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-11-25T20:00:26.000Z (6 months ago)
- Last Synced: 2024-11-25T20:38:48.185Z (6 months ago)
- Topics: ball-tree, knn, nearest-neighbor-search, vantage-point-tree
- Language: Rust
- Homepage:
- Size: 104 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# petal-neighbors
Nearest neighbor search algorithms including a ball tree and a vantage point tree.
[](https://crates.io/crates/petal-neighbors)
[](https://docs.rs/petal-neighbors)
[](https://codecov.io/gh/petabi/petal-neighbors)## Examples
The following example shows how to find two nearest neighbors in a ball tree.
```rust
use ndarray::{array, aview1};
use petal_neighbors::BallTree;let points = array![[1., 1.], [1., 2.], [9., 9.]];
let tree = BallTree::euclidean(points).unwrap();
let (indices, distances) = tree.query(&aview1(&[3., 3.]), 2);
assert_eq!(indices, &[1, 0]); // points[1] is the nearest, points[0] the next.
```## License
Copyright 2019-2024 Petabi, Inc.
Licensed under [Apache License, Version 2.0][apache-license] (the "License");
you may not use this crate except in compliance with the License.Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See [LICENSE](LICENSE) for
the specific language governing permissions and limitations under the License.## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the [Apache-2.0
license][apache-license], shall be licensed as above, without any additional
terms or conditions.[apache-license]: http://www.apache.org/licenses/LICENSE-2.0