TypeError: __init__() got an unexpected keyword argument 'n_topics'

问题遇到的现象和发生背景

在spyders上做LDA模型

问题相关代码,运行结果及报错内容

from sklearn.decomposition import LatentDirichletAllocation

n_components = 3

lda = LatentDirichletAllocation(n_topics=n_components, max_iter=50,
learning_method='online',
learning_offset=50.,
random_state=0)
lda.fit(tf)
TypeError: init() got an unexpected keyword argument 'n_topics'

看看是不是你那个方法写的不是n_topics

LatentDirichletAllocation这个方法没有n_topics这个参数,参数名是不是写错了