--- id: pynndescent version: "0.6.0" license: BSD-2-Clause license_treatment: permissive maintenance: active --- # pynndescent — Nearest Neighbor Descent License: permissive · Maintenance: active · Downloads: 7.0M/mo ## What it is and what it does PyNNDescent is a Python library for building approximate nearest neighbor (ANN) search indexes using the nearest neighbor descent algorithm, supplemented with random projection trees for initialization. It supports a large variety of distance metrics including euclidean, manhattan, cosine, hamming, wasserstein, and many others, as well as custom user-defined metrics. The library provides a simple two-operation interface: construct an index from training data, then query it for the k nearest neighbors of new points. It integrates with scikit-learn and can serve as a drop-in replacement for KNeighborTransformer in algorithms that use nearest neighbor computations. The implementation relies on numba for JIT compilation and joblib for parallelization. Use it for: - Build a searchable index for similarity-based recommendation systems or content retrieval - Perform fast approximate k-nearest neighbor queries on high-dimensional embeddings or feature vectors - Integrate nearest neighbor search into scikit-learn pipelines as a preprocessing or feature transformation step - Find similar items across different distance metrics (e.g., cosine for text embeddings, euclidean for image features) - Construct k-neighbor graphs for clustering, graph-based learning, or dimensionality reduction algorithms ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. PyNNDescent builds approximate nearest neighbor search indexes using nearest neighbor descent algorithms, supporting a wide variety of distance metrics for fast k-neighbor queries on high-dimensional data. Yes. PyNNDescent is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive BSD-2-Clause license. It solves a well-defined problem with broad metric support and scikit-learn integration. Suitable for production use in recommendation systems, similarity search, and machine learning pipelines. ## Install pip install pynndescent uv add pynndescent poetry add pynndescent ## Installing pynndescent Before you install: Low friction: pure Python wheel with five runtime dependencies (scikit-learn, scipy, numba, llvmlite, joblib) that are standard in scientific Python. Last release 218 days ago with active repository maintenance and 969 stars. License in practice: BSD-2-Clause permissive license allows commercial and private use with minimal restrictions; suitable for most projects. Quickstart: pip install pynndescent from pynndescent import NNDescent index = NNDescent(data) index.query(query_data, k=15) Verify before relying: - Whether the 80%-100% accuracy rate claim applies to all distance metrics or only specific ones - Performance comparison details with other ANN libraries beyond the ann-benchmarks reference ## Package facts - License: BSD-2-Clause (permissive) - Python support: unspecified - Install friction: low - Maintenance: active - Downloads: 7.0M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags approximate nearest neighbor search, knn indexing library, ann algorithm python, nearest neighbor graph construction, fast similarity search, k-nearest neighbors index, distance metric search, approximate-search, knn-indexing, distance-metrics [View on SkillFed](https://skillfed.io/packages/pynndescent) · [View on PyPI](https://pypi.org/project/pynndescent/)