初始代码:文章来源:https://www.toymoban.com/news/detail-520495.html
pyLDAvis.enable_notebook()
pic = pyLDAvis.sklearn.prepare(lda, tf, tf_vectorizer)
pyLDAvis.save_html(pic, 'lda'+ str(n_topics)+'.html')
pyLDAvis.show(pic, open_browser=False, local=False)
报错结果如下,请问大家怎么解决呀?文章来源地址https://www.toymoban.com/news/detail-520495.html
TypeError Traceback (most recent call last)
<ipython-input-39-0dd69e6a0426> in <module>
1 pyLDAvis.enable_notebook()
----> 2 pic = pyLDAvis.sklearn.prepare(lda, tf, tf_vectorizer)
3 pyLDAvis.save_html(pic, 'lda'+ str(n_topics)+'.html')
4 pyLDAvis.show(pic, open_browser=False, local=False)
E:\ANACONDA\lib\site-packages\pyLDAvis\sklearn.py in prepare(lda_model, dtm, vectorizer, **kwargs)
93 """
94 opts = fp.merge(_extract_data(lda_model, dtm, vectorizer), kwargs)
---> 95 return pyLDAvis.prepare(**opts)
E:\ANACONDA\lib\site-packages\pyLDAvis\_prepare.py 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)
437 term_frequency = np.sum(term_topic_freq, axis=0)
438
--> 439 topic_info = _topic_info(topic_term_dists, topic_proportion,
440 term_frequency, term_topic_freq, vocab, lambda_step, R,
441 n_jobs, start_index)
E:\ANACONDA\lib\site-packages\pyLDAvis\_prepare.py in _topic_info(topic_term_dists, topic_proportion, term_frequency, term_topic_freq, vocab, lambda_step, R, n_jobs, start_index)
244 'Total': term_frequency,
245 'Category': 'Default'})
--> 246 default_term_info = default_term_info.sort_values(
247 by='saliency', ascending=False).head(R).drop('saliency', 1)
248 # Rounding Freq and Total to integer values to match LDAvis code:
TypeError: drop() takes from 1 to 2 positional arguments but 3 were given
到了这里,关于Jupytor运行pyLDAvis输出结果时报错:TypeError: drop() takes from 1 to 2 positional arguments but 3 were given的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!