Learn R Programming

sentopics (version 1.0.0)

coherence: Coherence of estimated topics

Description

Computes various coherence based metrics for topic models. It assesses the quality of estimated topics based on co-occurrences of words. For best results, consider cleaning the initial tokens object with padding = TRUE.

Usage

coherence(
  x,
  nWords = 10,
  method = c("C_NPMI", "C_V"),
  window = NULL,
  NPMIs = NULL
)

Value

A vector or matrix containing the coherence score of each topic.

Arguments

x

a model created from the LDA(), JST() or rJST() function and estimated with fit()

nWords

the number of words in each topic used for evaluation.

method

the coherence method used.

window

optional. The maximum distance between two tokens to be considered co-occurring for the coherence measure. Distance is expressed in token positions. If NULL, use the default window for each coherence metric (10 for C_NPMI and 110 for C_V). Providing an integer or "boolean" to this argument will override the default. If "boolean", co-occurences will simply take place if the two words are present in the same document. This argument has no effect if the NPMIs argument is also provided.

NPMIs

optional NPMI matrix. If provided, skip the computation of NPMI between words, substantially decreasing computing time.

Author

Olivier Delmarcelle

Details

Currently, only C_NPMI and C_V are documented. The implementation follows Röder & al. (2015). For C_NPMI, the sliding window is 10 whereas it is 110 for C_V.

References

Röder, M., Both, A., & Hinneburg, A. (2015). Exploring the Space of Topic Coherence Measures. In Proceedings of the Eighth ACM International Conference on Web Search and Data Mining, 399-–408.