The package recursively partitions data using randomly sampled hyperplanes, producing a binary tree whose leaves contain small subsets of the original dataset.
- Single-file Python module (no package directory)
- Randomized ANN tree construction Works directly with Pandas DataFrames
- Supports arbitrary numeric feature subsets
- Simple tree and node abstraction
Clone the repository and install locally:
pip install .Or install in editable mode for development:
pip install -e .Since this is a single-file module, installation uses py_modules instead of packages.
The core functionality requires:
- Python 3.8+
- pandas
- numpy
.
├── mannr.py
├── setup.py
└── README.mdANN Tree Construction
The tree is built recursively using a random hyperplane split:
-
Two rows are randomly sampled from the dataset.
-
Their midpoint defines a center.
-
The vector between them defines a hyperplane.
-
All points are split based on which side of the hyperplane they lie on.
-
Recursion continues until the subset size is ≤ k.
This approach is inspired by randomized ANN methods such as RP-trees.
A node is considered a leaf if at least one child is missing.
Traversal uses a queue (collections.deque).
Intended for debugging or exploration, not analysis
import pandas as pd
from mannr import gen_ann_tree, find_leaves
df = pd.read_csv("data.csv")
features = ["x", "y"]
root = gen_ann_tree(df, features, k=20)
leaves = find_leaves(root)