# PyNNDescent

> Python implementation of Nearest Neighbor Descent for k-neighbor-graph construction and ANN search. Targets 80%-100% accuracy with fast performance and supports wide variety of distance metrics. This is an OSS library.

- **URL:** https://github.com/lmcinnes/pynndescent
- **Category:** Sdks & Libraries
- **Tags:** Open Source, Python, Ann
- **Updated:** 2026-03-06 18:05
- **Canonical page:** https://vectordb.ever.works/items/pynndescent

## Details

## Overview

PyNNDescent provides a Python implementation of Nearest Neighbor Descent for k-neighbor-graph construction and approximate nearest neighbor search. Based on a 2011 ACM paper focusing on high-accuracy ANN searches.

## Key Features

- **Fast Performance**: Among the fastest ANN libraries
- **Easy Installation**: pip and conda installable, no platform issues
- **Flexible**: Supports wide variety of distance metrics
- **High Accuracy**: Targets 80%-100% accuracy rate
- **Scikit-learn Integration**: Provides KNeighborTransformer support
- **Pure Python**: No compilation required

## Performance Characteristics

- Performs solidly in ann-benchmarks top performing libraries
- Fast approximate nearest neighbor queries
- Efficient k-neighbor-graph construction
- Good accuracy/speed trade-off

## Technical Approach

### Nearest Neighbor Descent
- Core algorithm from 2011 ACM paper by Dong, Wei, Charikar Moses, and Kai Li
- Efficient graph construction
- Iterative refinement

### Enhancements
- **Random Projection Trees**: Used for initialization
- **Graph Diversification**: Prunes longest edges of triangles
- **Optimized Search**: Efficient query algorithms

## Distance Metrics

Supports extensive list of metrics:
- Euclidean, Manhattan, Chebyshev
- Minkowski, Hamming, Cosine
- Correlation, Jaccard, Dice
- And many more specialized metrics

## Installation

### PyPI
```bash
pip install pynndescent
```

### Conda
```bash
conda install pynndescent
```

## Scikit-learn Integration

- KNeighborTransformer support
- Compatible with sklearn pipelines
- Fits into existing ML workflows
- Drop-in replacement for sklearn's KNN

## Use Cases

- High-accuracy ANN search (80%+ recall)
- K-neighbor graph construction
- Dimensionality reduction
- Clustering preprocessing
- Manifold learning
- Similarity search

## API

Simple Python interface:
```python
from pynndescent import NNDescent

index = NNDescent(data)
neighbors, distances = index.query(query_data, k=10)
```

## Comparison to Alternatives

### Advantages
- Easy installation (pure Python)
- No platform-specific issues
- Flexible distance metrics
- High accuracy focus
- Good scikit-learn integration

### Trade-offs
- May be slower than C++-based libraries for some workloads
- Memory usage vs. compiled alternatives
- Best for accuracy-focused applications

## Documentation

- Comprehensive ReadTheDocs documentation
- Example notebooks on GitHub
- API reference
- Tutorial materials

## Community

- GitHub: lmcinnes/pynndescent
- Active maintenance
- Responsive to issues
- Regular updates

## License

2-clause BSD licensed - permissive open-source license

## Related Projects

From the same author:
- UMAP (dimensionality reduction)
- HDBSCAN (clustering)

## Pricing

Free and open-source under BSD license. No licensing costs.

---

_This Markdown mirror is generated by Ever Works for AI agents. The canonical HTML page is at https://vectordb.ever.works/items/pynndescent._
