lda_strategy
Topic extraction with LDA (Latent Dirichlet Allocation).
extract_topics_with_lda(docs, *, min_document_frequency, n_topics)
Extracts topics from a list of documents using LDA method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docs |
list[str]
|
List of documents. |
required |
min_document_frequency |
float
|
CountVectorizer parameter - Minimum document frequency for the word to appear on the bag of words. |
required |
n_topics |
int
|
LDA parameter - Number of topics to generate. |
required |
Returns:
| Type | Description |
|---|---|
list[list[str]]
|
list of topics, where a topic is a list of words. |
Examples:
>>> extract_topics_with_lda(
... docs=["detecting code smells with machine learning", "code smells detection tools", "error detection in Java software with machine learning"],
... min_document_frequency=0.1,
... n_topics=2,
... )
[["word1 topic1", "word2 topic1"], ["word1 topic2", "word2 topic2"]]
Source code in src/sesg/topic_extraction/lda_strategy.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |