GridSearchCV给出“ __init __得到了意外的关键字参数'n_topics'”错误

问题描述

我正在google collab笔记本中运行以下代码。我已经研究了这种类型的错误,并确保在0.24.dev0之前更新我的sklearn版本,但该错误不断发生。有人可以帮忙吗?

search_params = {'n_components': [5,10,15,20,25],'learning_decay': [.5,.7,.9]}

lda = LatentDirichletAllocation(max_iter=5,learning_method='online',learning_offset=50.,random_state=0)

model = GridSearchCV(lda,param_grid=search_params)

model.fit(data_vectorized)

GridSearchCV(cv=None,error_score='raise',estimator=LatentDirichletAllocation(batch_size=128,doc_topic_prior=None,evaluate_every=-1,learning_decay=0.7,learning_method=None,learning_offset=10.0,max_doc_update_iter=100,max_iter=10,mean_change_tol=0.001,n_components=10,n_jobs=1,n_topics=None,perp_tol=0.1,random_state=None,topic_word_prior=None,total_samples=1000000.0,verbose=0),fit_params=None,iid=True,param_grid={'n_topics': [5,'learning_decay': [0.5,0.7,0.9]},pre_dispatch='2*n_jobs',refit=True,return_train_score='warn',scoring=None,verbose=0)

解决方法

来自sklearn documentation

版本0.19中的更改:n_topics重命名为n_components

似乎所有版本> = 0.19都保留此更改(我检查了0.23)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...