MaartenGr / MaartenGr/BERTopic

bug with custom_labels in _topics_over_time.py

Open
#1,504 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 bu in _topics_over_time.py when using custom_labels. In line 67, you loop over topics, but I think it should be selected_topics. My local fix for this line is:

topic_names = [[[str(topic), None]] + topic_model.topic_aspects_[custom_labels][topic] for topic in selected_topics]

Furthermore, line 70 also break down, as you are iterating over all topics and topic_names many not include all of them. I have changed it to:

topic_names = {key: topic_names[index] for index, key in enumerate(selected_topics)}

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 _topics_over_time.py at lines 67 and 70, then reproduce the custom_labels case with a subset of selected_topics. Verify that topic names are generated and mapped only for the selected topics, and confirm the behavior with the relevant existing tests or a focused reproduction.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.