current position:Home>TypeError: visibel() missing 2 required positional arguments: 'topic_ num' and 'data_ num'

TypeError: visibel() missing 2 required positional arguments: 'topic_ num' and 'data_ num'

2022-01-27 03:00:26 CSDN Q & A

#………………( Omit )#text = [list(np.arange(0, y)) for y in n_word]class yy:    def weibo_lda(self):        #text = self.result()        dictionary = Dictionary(text)        corpus = [dictionary.doc2bow(tmp) for tmp in text]        return dictionary, corpus    def choose_topic(self):        dictionary, corpus = self.weibo_lda()        texts = text        for i in range(1,6):            print(' current topic Number :{}'.format(i))            print(' Current data volume :{}'.format(len(texts)))            temp = 'lda_{}_{}'.format(i,len(texts))            tmp = gensim.models.ldamodel.LdaModel(corpus, num_topics=i, id2word=dictionary, passes=20)            file_path = './{}.model'.format(temp)              print('------------------')    def perplexity_visible_model(self, topic_num, data_num):        # texts = self.fenci_data()        _, corpus = self.weibo_lda()        x_list = []        y_list = []        for i in range(1,topic_num):            model_name = './lda_{}_{}.model'.format(i, data_num)            try:                lda = gensim.models.ldamodel.LdaModel.load(model_name)                perplexity = lda.log_perplexity(corpus)                print(perplexity)                x_list.append(i)                y_list.append(perplexity)            except Exception as e:                print(e)        plt.xlabel('num topics')        plt.ylabel('perplexity score')        plt.legend(('perplexity_values'), loc='best')    def visibel(self, topic_num, data_num):        dictionary, corpus = self.weibo_lda()        model_name = './lda_{}_{}.model'.format(topic_num, data_num)        lda = gensim.models.ldamodel.LdaModel.load(model_name)        vis_data = pyLDAvis.gensim.prepare(lda, corpus, dictionary), open_browser=False)if __name__=='__main__':    t = yy()    t.visibel()

Report errors :TypeError: visibel() missing 2 required positional arguments: 'topic_num' and 'data_num'


Refer to the answer 1:

You passed the parameters in -.-#

Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended