0

TypeError Traceback (most recent call last) Cell In[301], line 4 2 pyLDAvis.enable_notebook() 3 # lda_model = LdaMulticore(corpus=list(df_proc['vec']), id2word=dictionary, iterations=50, num_topics=12, passes=30) ----> 4 lda_display = pyLDAvis.gensim_models.prepare(lda_model,list(df_proc['vec']), dictionary) 5 pyLDAvis.display(lda_display)

File ~\AppData\Roaming\Python\Python39\site-packages\pyLDAvis\gensim_models.py:123, in prepare(topic_model, corpus, dictionary, doc_topic_dist, **kwargs) 78 """Transforms the Gensim TopicModel and related corpus and dictionary into 79 the data structures needed for the visualization. 80 (...) 120 See pyLDAvis.prepare for **kwargs. 121 """ 122 opts = fp.merge(_extract_data(topic_model, corpus, dictionary, doc_topic_dist), kwargs) --> 123 return pyLDAvis.prepare(**opts)

File ~\AppData\Roaming\Python\Python39\site-packages\pyLDAvis_prepare.py:432, in prepare(topic_term_dists, doc_topic_dists, doc_lengths, vocab, term_frequency, R, lambda_step, mds, n_jobs, plot_opts, sort_topics, start_index) 426 # Quick fix for red bar width bug. We calculate the 427 # term frequencies internally, using the topic term distributions and the 428 # topic frequencies, rather than using the user-supplied term frequencies. 429 # For a detailed discussion, see: https://github.com/cpsievert/LDAvis/pull/41 430 term_frequency = np.sum(term_topic_freq, axis=0) --> 432 topic_info = _topic_info(topic_term_dists, topic_proportion, 433 term_frequency, term_topic_freq, vocab, lambda_step, R, 434 n_jobs, start_index) 435 token_table = _token_table(topic_info, term_topic_freq, vocab, term_frequency, start_index) 436 topic_coordinates = _topic_coordinates(mds, topic_term_dists, topic_proportion, start_index)

File ~\AppData\Roaming\Python\Python39\site-packages\pyLDAvis_prepare.py:243, in _topic_info(topic_term_dists, topic_proportion, term_frequency, term_topic_freq, vocab, lambda_step, R, n_jobs, start_index) 236 # Order the terms for the "default" view by decreasing saliency: 237 default_term_info = pd.DataFrame({ 238 'saliency': saliency, 239 'Term': vocab, 240 'Freq': term_frequency, 241 'Total': term_frequency, 242 'Category': 'Default'}) --> 243 default_term_info = default_term_info.sort_values( 244 by='saliency', ascending=False).head(R).drop('saliency', 1) 245 # Rounding Freq and Total to integer values to match LDAvis code: 246 default_term_info['Freq'] = np.floor(default_term_info['Freq'])

TypeError: drop() takes from 1 to 2 positional arguments but 3 were given

I have tried to change the default errors

harivilas
  • 11
  • 2

0 Answers0