LatentDirichletAllocation<T>
Models & Types ยท AiDotNet.Preprocessing.DimensionalityReduction
Latent Dirichlet Allocation for topic modeling.
Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> โ LatentDirichletAllocation<T>
For Beginners
LDA finds hidden themes (topics) in your data:
- Input: Document-term matrix (rows=documents, columns=word counts)
- Output: Document-topic distribution (what topics each document is about)
- Also learns: Topic-word distribution (what words define each topic)
- Use for: Topic modeling, document clustering, feature extraction
How It Works
LDA is a generative probabilistic model that discovers latent topics in a collection of documents (or more generally, in count data). Each document is modeled as a mixture of topics, and each topic is a distribution over words (features).
The model assumes:
- Each document has a distribution over topics (theta)
- Each topic has a distribution over words (beta)
- Words in documents are generated by first sampling a topic, then sampling a word
Constructors
| Constructor | Summary |
|---|---|
LatentDirichletAllocation(int nComponents, double? docTopicPrior, double? topicWordPrior, LdaLearningMethod learningMethod, int maxIter, double tol, int batchSize, int? randomState, int[] columnIndices) |
Creates a new instance of LatentDirichletAllocation. |
Properties
| Property | Summary |
|---|---|
LdaLearningMethod LearningMethod { get; } |
Gets the learning method. |
Matrix<T> Components { get; } |
Gets the topic-word distribution matrix (topics x vocabulary). |
bool SupportsInverseTransform { get; } |
Gets whether this transformer supports inverse transformation. |
double DocTopicPrior { get; } |
Gets the document-topic prior (alpha). |
double TopicWordPrior { get; } |
Gets the topic-word prior (beta/eta). |
int NComponents { get; } |
Gets the number of topics. |
int NVocab { get; } |
Gets the vocabulary size. |
Methods
| Method | Summary |
|---|---|
string[] GetFeatureNamesOut(string[] inputFeatureNames) |
Gets the output feature names after transformation. |
string[][] GetTopWordsPerTopic(int nTopWords, string[] featureNames) |
Gets the top words for each topic. |