NMF topic modeling
In this recipe, we will use another unsupervised topic modeling technique, NMF. We will also explore another evaluation technique, topic model coherence. NMF topic modeling is very fast and memory efficient and works best with sparse corpora.
Getting ready
We will continue using the gensim
package in this recipe.
How to do it…
We will create an NMF topic model and evaluate it using the coherence measure, which measures human topic interpretability. Many of the functions used for NMF models are the same as for LDA models in the gensim
package. The steps for this recipe are as follows:
- Perform the necessary imports:
import re import pandas as pd from gensim.models.nmf import Nmf from gensim.models import CoherenceModel import gensim.corpora as corpora from gensim.utils import simple_preprocess import matplotlib.pyplot as plt from pprint import pprint from Chapter06.lda_topic_sklearn import stopwords, bbc_dataset, new_example from Chapter06...