Let's say you are give 1 millions questions from Quora. And ask to categorize. them based on the question type. This simply is a application of topic modeling.
You can choose to do this two ways:
Latent Dirichlet Allocation
Non Negative Matrix Factorization.
Using NMF:
Import the data
for nmf, we can use tfidfvectorizer
fit_transform the data into TFidfVectorizer
Once the data is ready, we can import NMF from sklearn
instantiate the nmfModel with amount of topic we want to model
we can say we want 20 topics out of these 1 million question
or we want 5 topics out of these 1 million question
then we fit our NMF model with our tfidf vectorized data
now we have the topic modeling done
we can check our top words that are responsible for the topic.
however the 1 topic out of these top words we have name it.
import pandas as pd
quora = pd.read_csv(quora_data)
from sklearn.feature_extraction.text import TfidfVectorizer
How to perform topic modeling using NMF?
why is it useful?
Let's say you are give 1 millions questions from Quora. And ask to categorize. them based on the question type. This simply is a application of topic modeling.
You can choose to do this two ways:
Using NMF:
here we have document term matrix we are now going to use NMF model
here we can see words in this fashion:
now it's upto us to decide what these word represents and topic model it out.
also you can attach the topic to the quora variable we mentioned in the steps by:
if we further want to put a subject on the topic, which is varibale we can define a dictionary lile: