MaartenGr / MaartenGr/BERTopic
topics_per_class on a subset of docs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
Hi!
I have compiled answers to multiple questions into docs to create a topic model considering all answers. However, for visualization, I want to plot one figure for each question. Particularly, I want to show the bar charts of topics per class, for each question separately.
Here's my code:
q1 = data['Question1'] # part of my docs list
group1 = data.dropna(subset=['Q1'])[['group']]
group1_list = groups1['group'].tolist() # classes for q1 documents
topics_per_class_q1 = topic_model.topics_per_class(q1, group1_list)
But I get a "ValueError: All arrays must be of the same length" on the last line.
I am sure q1 and group1_list have the same length. Any ideas on where the mismatch is happening and how this can be achieved?
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 at the topic_model.topics_per_class(q1, group1_list) entry point and reproduce the reported ValueError using the issue's example. Check the lengths and naming of q1, group1_list, and the selected data columns, then verify that separate topic-per-class results can be produced for the question subset without the array-length error.
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