How to Do Topic Modelling and Classification on Each Sentence Comment in a Data Frame in R?

226 Views Asked by At

Is there a way to do topic modelling and classification on a data frame of comments in R?

I have 10 columns of comments (where each comment is a open ended sentence of a topic related to a question) and I want to classify each of these comments by topic for each column of comments.

I tried to use LDA (Latent Dirichlet Allocation) using the topicmodels package in R (and use DocumentTermMatrix and Corpus before I applied the LDA model). I tried to find the optimal number of topics using the lowest perplexity.

The issue is that I don't know what topic each sentence of a comment is classified by. It does put words into a similar topic but not by sentence. So it's a little confusing.

I don't know where to go from there and need advice on how to do this.

I was able to apply Sentimental Analysis on the same data frame in R using the sentimentr package and it worked but I can't do the same for topic modelling and classification.

How can I do this in R for each sentence of comment in a column (for a total of 10 columns)?

image of data

0

There are 0 best solutions below