MaartenGr / MaartenGr/BERTopic

bug with custom_labels in _hierarchy.py

Open
#1,503 3 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.