lmcinnes / lmcinnes/pynndescent
true_angular is not a distance?
- Dominant language
- Python
- Stars
- 970
- Forks
- 107
- PR merge metrics
- No merged PRs in 30d
Description
This may be based on my lack of understanding as covered in https://github.com/lmcinnes/pynndescent/discussions/231 but it seems like the `true_angular` function returns a similarity and not a distance, i.e.:
```python
from sklearn.datasets import load_iris
iris = np.float32(load_iris().data)
import pynndescent.distances as dist
dist.cosine(iris[0], iris[0]), dist.cosine(iris[0], iris[1])
(0.0, 0.0014208250387670596)
dist.true_angular(iris[0], iris[0]), dist.true_angular(iris[0], iris[1])
(1.0, 0.9830298038991578)
```
Edited to add that `alternative_cosine` *is* a distance, which is what is actually used for finding nearest neighbors when `metric = "true_angular"`, although it gets transformed back into a similarity via `true_angular_from_alt_cosine` at the end).
Contributor guide
Research direction
Start with the pynndescent.distances implementations of true_angular, alternative_cosine, and true_angular_from_alt_cosine, then trace how metric="true_angular" is used for nearest-neighbor search. Compare the documented and observed similarity or distance semantics, and consider the issue resolved when the public behavior is consistent and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning, search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100