31-07-2025, 03:44 PM
(31-07-2025, 03:35 PM)nablator wrote: You are not allowed to view links. Register or Login to view.Isn't the number of topics a parameter of LDA? Which approach/algorithm/implementation do you use for deciding how many topics there are?
I iterate through different topic numbers and calculate the Coherence Score, then I take the maximum. In the last case (without repetitive words) I got this scores:
![[Image: sv0H42X.png]](https://i.imgur.com/sv0H42X.png)
I use this function that uses gensim LdaModel and CoherenceModel
Code:
# 4. Coherence computation function
def compute_coherence(dictionary, corpus, texts, start=2, limit=15, step=1):
coherence_values = []
model_list = []
for num_topics in range(start, limit + 1, step):
model = LdaModel(
corpus=corpus,
id2word=dictionary,
num_topics=num_topics,
random_state=42,
passes=20,
alpha='auto'
)
model_list.append(model)
coherencemodel = CoherenceModel(
model=model,
texts=texts,
dictionary=dictionary,
coherence='c_v'
)
coherence_values.append(coherencemodel.get_coherence())
return model_list, coherence_values

![[+]](https://www.voynich.ninja/images/collapse_collapsed.png)