MaartenGr / MaartenGr/BERTopic
metric= "cosine" error reported
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
### Have you searched existing issues? 🔎
- [X] I have searched and found no existing issues
### Desribe the bug
I wanted to set cosine to represent the distance parameter when I personalized hdbscan. This instantiation didn't go wrong, but I passed the instantiation hdbscan_model into BERTopic(). Unrecognized metric 'cosine'
### Reproduction
```python
from bertopic import BERTopic
hdbscan_model = HDBSCAN(
min_cluster_size=200,,
min_samples=20,
metric='cosine',
prediction_data=True
)
topic_model = BERTopic(embedding_model=transformer_model,
#min_topic_size=3,
verbose=True,
umap_model=umap_model,
hdbscan_model=hdbscan_model,
ctfidf_model=ctfidf_model,
representation_model=representation_model,
#top_n_words=10,
#min_topic_size=10,
#nr_topics=None,
#low_memory=False,
#calculate_probabilities=True
)
topics,probs=topic_model.fit_transform(sentences,embeddings=embeddings)
```
### BERTopic Version
0.16.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied HDBSCAN and BERTopic reproduction with BERTopic 0.16.4, focusing on where the custom hdbscan_model is accepted during fit_transform. Trace the handling of the metric='cosine' configuration and compare the reported error with HDBSCAN's supported metrics. Done means cosine works through this integration or the incompatibility is clearly reported and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100