R: Probabilistic coherence of topics

CalcProbCoherence {textmineR} | R Documentation

## Probabilistic coherence of topics

### Description

Calculates the probabilistic coherence of a topic or topics. This approximates semantic coherence or human understandability of a topic.

### Usage

    CalcProbCoherence(phi, dtm, M = 5)

### Arguments

`phi` | A numeric matrix or a numeric vector. The vector, or rows of the matrix represent the numeric relationship between topic(s) and terms. For example, this relationship may be p(word|topic) or p(topic|word).
`dtm` | A document term matrix or co-occurrence matrix of class `matrix` or whose class inherits from the `Matrix` package. Columns must index terms.
`M` | An integer for the number of words to be used in the calculation. Defaults to 5

### Value

Returns an object of class `numeric` corresponding to the probabilistic coherence of the input topic(s).

### Examples

    # Load a pre-formatted dtm and topic model
    data(nih_sample_topic_model)
    data(nih_sample_dtm)

    CalcProbCoherence(phi = nih_sample_topic_model$phi, dtm = nih_sample_dtm, M = 5)

[Package textmineR version 3.0.5 Index]