topic_coherence.segmentation – Segmentation module¶This module contains functions to perform segmentation on a list of topics.
gensim.topic_coherence.segmentation.s_one_one(topics)¶This function performs s_one_one segmentation on a list of topics. s_one_one segmentation is defined as: s_one_one = {(W’, W*) | W’ = {w_i}; W* = {w_j}; w_i, w_j belongs to W; i != j} .. rubric:: Example
>>> topics = [np.array([1, 2, 3]), np.array([4, 5, 6])]
>>> s_one_pre(topics)
[[(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)], [(4, 5), (4, 6), (5, 4), (5, 6), (6, 4), (6, 5)]]
| Parameters: | topics – list of topics obtained from an algorithm such as LDA. Is a list such as [array([ 9, 10, 11]), array([ 9, 10, 7]), …] |
|---|---|
| Returns: | list of list of (W’, W*) tuples for all unique topic ids |
| Return type: | s_one_one_res |
gensim.topic_coherence.segmentation.s_one_pre(topics)¶This function performs s_one_pre segmentation on a list of topics. s_one_pre segmentation is defined as: s_one_pre = {(W’, W*) | W’ = {w_i}; W* = {w_j}; w_i, w_j belongs to W; i > j} .. rubric:: Example
>>> topics = [np.array([1, 2, 3]), np.array([4, 5, 6])]
>>> s_one_pre(topics)
[[(2, 1), (3, 1), (3, 2)], [(5, 4), (6, 4), (6, 5)]]
| Parameters: | topics – list of topics obtained from an algorithm such as LDA. Is a list such as [array([ 9, 10, 11]), array([ 9, 10, 7]), …] |
|---|---|
| Returns: | list of list of (W’, W*) tuples for all unique topic ids |
| Return type: | s_one_pre_res |
gensim.topic_coherence.segmentation.s_one_set(topics)¶This function performs s_one_set segmentation on a list of topics. s_one_set segmentation is defined as: s_one_set = {(W’, W*) | W’ = {w_i}; w_i belongs to W; W* = W} .. rubric:: Example
>>> topics = [np.array([9, 10, 7])
>>> s_one_set(topics)
[[(9, array([ 9, 10, 7])),
(10, array([ 9, 10, 7])),
(7, array([ 9, 10, 7]))]]
| Parameters: | topics – list of topics obtained from an algorithm such as LDA. Is a list such as [array([ 9, 10, 11]), array([ 9, 10, 7]), …] |
|---|---|
| Returns: | list of list of (W’, W*) tuples for all unique topic ids. |
| Return type: | s_one_set_res |