Cluster2TopicModel: Represent a document clustering as a topic model

View source: R/topic_modeling_core.R

Cluster2TopicModelR Documentation

Represent a document clustering as a topic model

Description

Represents a document clustering as a topic model of two matrices. phi: P(term | cluster) theta: P(cluster | document)

Usage

Cluster2TopicModel(dtm, clustering, ...)

Arguments

dtm

A document term matrix of class dgCMatrix or whose class inherits from the Matrix package. Columns must index terms, rows must index documents.

clustering

A vector of length nrow(dtm) whose entries form a partitional clustering of the documents.

...

Other arguments to be passed to TmParallelApply.

Value

Returns a list with two elements, phi and theta. 'phi' is a matrix whose j-th row represents P(terms | cluster_j). 'theta' is a matrix whose j-th row represents P(clusters | document_j). Each row of theta should only have one non-zero element.

Examples

## Not run: 
# Load pre-formatted data for use
data(nih_sample_dtm)
data(nih_sample) 

result <- Cluster2TopicModel(dtm = nih_sample_dtm, 
                             clustering = nih_sample$IC_NAME)

## End(Not run)

TommyJones/textmineR documentation built on July 26, 2023, 9:51 p.m.