Jupytor运行pyLDAvis输出结果时报错:TypeError: drop() takes from 1 to 2 positional arguments but 3 were given

初始代码:

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)

报错结果如下,请问大家怎么解决呀?

TypeError                                 Traceback (most recent call last)
 in 
      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

你可能感兴趣的:(sklearn,人工智能,python)