MaartenGr / MaartenGr/BERTopic
bug with custom_labels in _hierarchy.py
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
Hi,
it seems there is a bug in _hierarchy.py when using aspects as custom labels. In line 151, fig.layout[axis]["ticktext"] returns a list of strings, but topics are indexed by ints in topic_model.topic_aspects_. I did a local fix by introducing a type cast in line 151 to
new_labels = [[[str(x), None]] + topic_model.topic_aspects_[custom_labels][int(x)] for x in fig.layout[axis]["ticktext"]]
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 in _hierarchy.py around line 151 and reproduce the hierarchy view with aspects used as custom labels. Compare the string values from fig.layout[axis]["ticktext"] with the integer keys in topic_model.topic_aspects_; done means custom aspect labels work without the lookup failure, with a regression test if the repository’s testing structure supports it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100