You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I implemented Cosine Distance as a DistanceMetric. It is a common distance metric used for text embeddings. Let me know what I can do to get this merged!
Hey @carterharrison, thanks for contributing! My HDBSCAN implementation uses a KD Tree nearest neighbours algorithm to calculate distances to the kth (min_samples-th) neighbour. I've shied away from implementing cosine distance in the past as it
it's not commonly used with KD Trees. As I understand it, KD Tree NN is largely designed to work efficiently with distance metrics that satisfy the properties of Euclidean space and queries using cosine distance can become inefficient quickly, particularly as dimensionality increases. It is more common to use cosine distance with the Ball Tree NN algorithm (which I haven't been able to support yet).
That said, I tried this out on a couple of test datasets and the clusters looked good, albeit very similar results to Euclidean distance. As such I have nothing against merging it.
Have you tested it at all? If so, are you happy with the quality of clusters and performance?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I implemented Cosine Distance as a DistanceMetric. It is a common distance metric used for text embeddings. Let me know what I can do to get this merged!