topic_modeling/lda.py
def create_model(self, documents, num_topics, passes=10):
        """
        Create LDA model.
        @documents - List of documents on which modeling is to be done
        @num_topics - Number of topics to look for
        @passes - Number of passes to run for creating model
                    higher -> more accurate but slower
        """
        texts = [self.pre_process(document) for document in documents]
        self.dictionary = corpora.Dictionary(texts)
        # CONVERT TO BAG OF WORDS
        corpus = [self.dictionary.doc2bow(text) for text in texts]
        ldamodel = models.ldamodel.LdaModel(
            corpus,
            num_topics=num_topics,
            id2word=self.dictionary,
            passes=passes
        )
        self.lda_model = ldamodel

        Create LDA model.
        @documents - List of documents on which modeling is to be done
        @num_topics - Number of topics to look for
        @passes - Number of passes to run for creating model
                    higher -> more accurate but slower
        
Create LDA model.
@documents - List of documents on which modeling is to be done
@num_topics - Number of topics to look for
@passes - Number of passes to run for creating model
higher -> more accurate but slower
Create LDA model . @documents - List of documents on which modeling is to be done @num_topics - Number of topics to look for @passes - Number of passes to run for creating model higher - > more accurate but slower
def create_model(self, documents, num_topics, passes=10):
        texts = [self.pre_process(document) for document in documents]
        self.dictionary = corpora.Dictionary(texts)
        corpus = [self.dictionary.doc2bow(text) for text in texts]
        ldamodel = models.ldamodel.LdaModel(
            corpus,
            num_topics=num_topics,
            id2word=self.dictionary,
            passes=passes
        )
        self.lda_model = ldamodel
def create_model ( self , documents , num_topics , passes = 10 ) : texts = [ self . pre_process ( document ) for document in documents ] self . dictionary = corpora . Dictionary ( texts ) corpus = [ self . dictionary . doc2bow ( text ) for text in texts ] ldamodel = models . ldamodel . LdaModel ( corpus , num_topics = num_topics , id2word = self . dictionary , passes = passes ) self . lda_model = ldamodel
Create LDA model.
Create LDA model .
"""
        Create LDA model.
        @documents - List of documents on which modeling is to be done
        @num_topics - Number of topics to look for
        @passes - Number of passes to run for creating model
                    higher -> more accurate but slower
        """ # CONVERT TO BAG OF WORDS
self
documents
num_topics
passes