bann 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bann-0.0.1/LICENSE +21 -0
- bann-0.0.1/MANIFEST.in +5 -0
- bann-0.0.1/PKG-INFO +82 -0
- bann-0.0.1/README.md +51 -0
- bann-0.0.1/ann_call.cpp +565 -0
- bann-0.0.1/ann_namespace.cpp +24 -0
- bann-0.0.1/bann.cpp +15600 -0
- bann-0.0.1/bann.egg-info/PKG-INFO +82 -0
- bann-0.0.1/bann.egg-info/SOURCES.txt +46 -0
- bann-0.0.1/bann.egg-info/dependency_links.txt +1 -0
- bann-0.0.1/bann.egg-info/not-zip-safe +1 -0
- bann-0.0.1/bann.egg-info/requires.txt +1 -0
- bann-0.0.1/bann.egg-info/top_level.txt +1 -0
- bann-0.0.1/bann.pyx +265 -0
- bann-0.0.1/cpp_src/ANN.cpp +205 -0
- bann-0.0.1/cpp_src/ANN.h +877 -0
- bann-0.0.1/cpp_src/ANNperf.h +223 -0
- bann-0.0.1/cpp_src/ANNx.h +172 -0
- bann-0.0.1/cpp_src/bd_fix_rad_search.cpp +62 -0
- bann-0.0.1/cpp_src/bd_pr_search.cpp +63 -0
- bann-0.0.1/cpp_src/bd_search.cpp +71 -0
- bann-0.0.1/cpp_src/bd_tree.cpp +417 -0
- bann-0.0.1/cpp_src/bd_tree.h +102 -0
- bann-0.0.1/cpp_src/brute.cpp +122 -0
- bann-0.0.1/cpp_src/divergence_config.h +72 -0
- bann-0.0.1/cpp_src/kd_dump.cpp +444 -0
- bann-0.0.1/cpp_src/kd_fix_rad_search.cpp +189 -0
- bann-0.0.1/cpp_src/kd_fix_rad_search.h +44 -0
- bann-0.0.1/cpp_src/kd_haus.cpp +126 -0
- bann-0.0.1/cpp_src/kd_haus.h +17 -0
- bann-0.0.1/cpp_src/kd_pr_search.cpp +228 -0
- bann-0.0.1/cpp_src/kd_pr_search.h +49 -0
- bann-0.0.1/cpp_src/kd_search.cpp +228 -0
- bann-0.0.1/cpp_src/kd_search.h +48 -0
- bann-0.0.1/cpp_src/kd_split.cpp +428 -0
- bann-0.0.1/cpp_src/kd_split.h +85 -0
- bann-0.0.1/cpp_src/kd_tree.cpp +405 -0
- bann-0.0.1/cpp_src/kd_tree.h +200 -0
- bann-0.0.1/cpp_src/kd_util.cpp +445 -0
- bann-0.0.1/cpp_src/kd_util.h +125 -0
- bann-0.0.1/cpp_src/perf.cpp +136 -0
- bann-0.0.1/cpp_src/pr_queue.h +130 -0
- bann-0.0.1/cpp_src/pr_queue_k.h +119 -0
- bann-0.0.1/pyproject.toml +3 -0
- bann-0.0.1/setup.cfg +31 -0
- bann-0.0.1/setup.py +48 -0
- bann-0.0.1/tests/test_bann.py +204 -0
bann-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tuyen P
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
bann-0.0.1/MANIFEST.in
ADDED
bann-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bann
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Cython wrapper for Bregman ANN searches
|
|
5
|
+
Home-page: https://github.com/tuqpham0/bann
|
|
6
|
+
Author: Tuyen Pham
|
|
7
|
+
Author-email: tuyen.pham@ufl.edu
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Development Status :: 1 - Planning
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: C++
|
|
16
|
+
Classifier: Programming Language :: Cython
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: numpy
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: author-email
|
|
26
|
+
Dynamic: license
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
Dynamic: requires-dist
|
|
29
|
+
Dynamic: requires-python
|
|
30
|
+
Dynamic: summary
|
|
31
|
+
|
|
32
|
+
# Bregman Approximate Nearest Neighbours for Python
|
|
33
|
+
This is a python wrapper for the (Decomposable) Bregman Approximate Nearest Neighbour(Bregman ANN, or BANN) package adapted by Hubert Wagner and Tuyen Pham. The original ANN package was written by David Mount and Sunil Arya. The original package uses Kd-trees to search for nearest neighbours in Euclidean space equipped with an $L^{p}$-norm. [See David Mount's page for documention for the original ANN package.](https://www.cs.umd.edu/~mount/ANN/)
|
|
34
|
+
|
|
35
|
+
For a Python wrapped version of the original ANN, see:
|
|
36
|
+
- [pyANN by Dmitriy Morozov](https://mrzv.org/software/pyANN/)
|
|
37
|
+
- [PyANN by Anna Nevison](https://github.com/annacnev/pyann)
|
|
38
|
+
|
|
39
|
+
#### Bregman Divergences
|
|
40
|
+
Bregman divergences are measurements of generalized distances in a space. Unlike metrics, they are often assymmetric and do not globally satisfy the triangle inequality. Recently, these divergences have been useful in machine learning, with the most prominent example being the Kullback--Leibler divergence.
|
|
41
|
+
|
|
42
|
+
## About
|
|
43
|
+
The BANN package currently uses Kd-trees for two primary computations:
|
|
44
|
+
- (approximate) $k$-nearest neighbour searches with decomposable Bregman divergences
|
|
45
|
+
- Bregman--Hausdorff divergence for decomposable Bregman divergences
|
|
46
|
+
|
|
47
|
+
Currently, this package supports the following divergences:
|
|
48
|
+
- Kullback--Leibler divergence (primal and dual)
|
|
49
|
+
- Itakura--Saito divergence (primal and dual)
|
|
50
|
+
- Squared Euclidean divergence
|
|
51
|
+
|
|
52
|
+
Additional decomposable divergences can be simply added to the source code, and passing a divergence from Python is a planned implementation.
|
|
53
|
+
|
|
54
|
+
### Details
|
|
55
|
+
Let $D_F:\Omega\times\Omega\to [0,\infty]$ be a decomposable Bregman divergence and let $P = \\{p_n\\}^N_{n=1}$, $Q = \\{q_m\\}^M_{m=1}$ be subsets of $\Omega$.
|
|
56
|
+
|
|
57
|
+
#### Bregman $k$-nn search
|
|
58
|
+
For $q\in Q$, the Bregman $k$-nearest neighbour search returns the ordered list of indices $(x_1,x_2,\dots,x_k)$, such that $D_F(q\\|p_{x_1})\leq D_F(q\\|p_{x_2})\leq\cdots\leq D_F(q\\|p_{x_k})$ and $D_F(q\\|p_{x_k})\leq D_F(q\\|p_{\ell})$ for all $\ell\notin\\{x_{1},x_{2},\dots,x_{k}\\}$. As Bregman divergences are rarely symmetric, we can reverse the arguments as necessary.
|
|
59
|
+
|
|
60
|
+
This package also supports $\epsilon$-approximate nearest neighbour searches, where the divergence to the reported nearest neighbour is at most $(1+\epsilon)$-times the divergence to the true nearest neighbour.
|
|
61
|
+
|
|
62
|
+
[Further details of using Kd-trees with Bregman Divergences are discussed here.](https://arxiv.org/abs/2502.13425)
|
|
63
|
+
|
|
64
|
+
#### Bregman—Hausdorff divergence
|
|
65
|
+
The Bregman—Hausdorff divergence generalizes the Bregman divergence between two vectors to the Bregman divergence between to *sets* of vectors. The Bregman—Hausdorff divergence was introduced by Pham, Dal Poz Kouřimská, and Wagner, where they also provide algorithms for its computation. Specifically, we compute
|
|
66
|
+
$$H_{D_F}(P\|Q) = \inf \\{r\geq0 : P\subseteq\bigcup_{q\in Q}B_F(q;r)\\}$$ and $$H_{D_F}' = \inf \\{r\geq0 : P\subseteq\bigcup_{q\in Q}B'_F(q;r)\\}$$ via the shell algorithm, where $B_F(q;r)=\\{x\in \Omega\,:\, D_F(q\|x)\leq r\\}$ and $B'_F(q;r) = \\{x\in \Omega\,:\,D_F(x\|q)\leq r\\}$. Note that the directions of computations for the Bregman--Hausdorff divergences are reversed compared to the directions for the nearest neighbour searches.
|
|
67
|
+
|
|
68
|
+
[The Bregman—Hausdorff divergence and shell algorithm for computation are introduced here.](https://www.mdpi.com/2504-4990/7/2/48)
|
|
69
|
+
|
|
70
|
+
#### Further details
|
|
71
|
+
For further details and example uses, see the [documentation](docs.md).
|
|
72
|
+
## Requirements
|
|
73
|
+
### Python Version
|
|
74
|
+
BANN requires Python >=3.11.
|
|
75
|
+
### Dependencies
|
|
76
|
+
- [Numpy](https://numpy.org/)
|
|
77
|
+
## Installation
|
|
78
|
+
|
|
79
|
+
## Feedback
|
|
80
|
+
Bug reports, pull requests after forking, and other questions may be sent to the maintainer: tuyen.pham@ufl.edu
|
|
81
|
+
## Copyright and License
|
|
82
|
+
See [Copyright](COPYRIGHT) and [License](LICENSE) for copyright and license information.
|
bann-0.0.1/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Bregman Approximate Nearest Neighbours for Python
|
|
2
|
+
This is a python wrapper for the (Decomposable) Bregman Approximate Nearest Neighbour(Bregman ANN, or BANN) package adapted by Hubert Wagner and Tuyen Pham. The original ANN package was written by David Mount and Sunil Arya. The original package uses Kd-trees to search for nearest neighbours in Euclidean space equipped with an $L^{p}$-norm. [See David Mount's page for documention for the original ANN package.](https://www.cs.umd.edu/~mount/ANN/)
|
|
3
|
+
|
|
4
|
+
For a Python wrapped version of the original ANN, see:
|
|
5
|
+
- [pyANN by Dmitriy Morozov](https://mrzv.org/software/pyANN/)
|
|
6
|
+
- [PyANN by Anna Nevison](https://github.com/annacnev/pyann)
|
|
7
|
+
|
|
8
|
+
#### Bregman Divergences
|
|
9
|
+
Bregman divergences are measurements of generalized distances in a space. Unlike metrics, they are often assymmetric and do not globally satisfy the triangle inequality. Recently, these divergences have been useful in machine learning, with the most prominent example being the Kullback--Leibler divergence.
|
|
10
|
+
|
|
11
|
+
## About
|
|
12
|
+
The BANN package currently uses Kd-trees for two primary computations:
|
|
13
|
+
- (approximate) $k$-nearest neighbour searches with decomposable Bregman divergences
|
|
14
|
+
- Bregman--Hausdorff divergence for decomposable Bregman divergences
|
|
15
|
+
|
|
16
|
+
Currently, this package supports the following divergences:
|
|
17
|
+
- Kullback--Leibler divergence (primal and dual)
|
|
18
|
+
- Itakura--Saito divergence (primal and dual)
|
|
19
|
+
- Squared Euclidean divergence
|
|
20
|
+
|
|
21
|
+
Additional decomposable divergences can be simply added to the source code, and passing a divergence from Python is a planned implementation.
|
|
22
|
+
|
|
23
|
+
### Details
|
|
24
|
+
Let $D_F:\Omega\times\Omega\to [0,\infty]$ be a decomposable Bregman divergence and let $P = \\{p_n\\}^N_{n=1}$, $Q = \\{q_m\\}^M_{m=1}$ be subsets of $\Omega$.
|
|
25
|
+
|
|
26
|
+
#### Bregman $k$-nn search
|
|
27
|
+
For $q\in Q$, the Bregman $k$-nearest neighbour search returns the ordered list of indices $(x_1,x_2,\dots,x_k)$, such that $D_F(q\\|p_{x_1})\leq D_F(q\\|p_{x_2})\leq\cdots\leq D_F(q\\|p_{x_k})$ and $D_F(q\\|p_{x_k})\leq D_F(q\\|p_{\ell})$ for all $\ell\notin\\{x_{1},x_{2},\dots,x_{k}\\}$. As Bregman divergences are rarely symmetric, we can reverse the arguments as necessary.
|
|
28
|
+
|
|
29
|
+
This package also supports $\epsilon$-approximate nearest neighbour searches, where the divergence to the reported nearest neighbour is at most $(1+\epsilon)$-times the divergence to the true nearest neighbour.
|
|
30
|
+
|
|
31
|
+
[Further details of using Kd-trees with Bregman Divergences are discussed here.](https://arxiv.org/abs/2502.13425)
|
|
32
|
+
|
|
33
|
+
#### Bregman—Hausdorff divergence
|
|
34
|
+
The Bregman—Hausdorff divergence generalizes the Bregman divergence between two vectors to the Bregman divergence between to *sets* of vectors. The Bregman—Hausdorff divergence was introduced by Pham, Dal Poz Kouřimská, and Wagner, where they also provide algorithms for its computation. Specifically, we compute
|
|
35
|
+
$$H_{D_F}(P\|Q) = \inf \\{r\geq0 : P\subseteq\bigcup_{q\in Q}B_F(q;r)\\}$$ and $$H_{D_F}' = \inf \\{r\geq0 : P\subseteq\bigcup_{q\in Q}B'_F(q;r)\\}$$ via the shell algorithm, where $B_F(q;r)=\\{x\in \Omega\,:\, D_F(q\|x)\leq r\\}$ and $B'_F(q;r) = \\{x\in \Omega\,:\,D_F(x\|q)\leq r\\}$. Note that the directions of computations for the Bregman--Hausdorff divergences are reversed compared to the directions for the nearest neighbour searches.
|
|
36
|
+
|
|
37
|
+
[The Bregman—Hausdorff divergence and shell algorithm for computation are introduced here.](https://www.mdpi.com/2504-4990/7/2/48)
|
|
38
|
+
|
|
39
|
+
#### Further details
|
|
40
|
+
For further details and example uses, see the [documentation](docs.md).
|
|
41
|
+
## Requirements
|
|
42
|
+
### Python Version
|
|
43
|
+
BANN requires Python >=3.11.
|
|
44
|
+
### Dependencies
|
|
45
|
+
- [Numpy](https://numpy.org/)
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
## Feedback
|
|
49
|
+
Bug reports, pull requests after forking, and other questions may be sent to the maintainer: tuyen.pham@ufl.edu
|
|
50
|
+
## Copyright and License
|
|
51
|
+
See [Copyright](COPYRIGHT) and [License](LICENSE) for copyright and license information.
|