【发布时间】:2020-06-29 07:08:34
【问题描述】:
我正在对文本数据(大约 4000 篇新闻文章)进行主题建模。为此,我使用的是 Sklearn LDA 模型。在执行此操作时,我使用 GridSearchCV 来选择最佳模型。然而,在几乎所有情况下,GridSearchCV 都建议将最少主题作为最佳模型。
例如1:
# Define Search Param
search_params = {'n_components': [5, 7, 10, 12, 15, 18, 20], 'learning_decay': [.5, .7, .9]}
# Init the Model
lda = LatentDirichletAllocation()
# Init Grid Search Class
model = GridSearchCV(lda, param_grid=search_params)
# Do the Grid Search
model.fit(data_vectorized)
建议的最佳模型:5
示例 2:
# Define Search Param
search_params = {'n_components': [3, 5, 7, 10, 12, 15, 18], 'learning_decay': [.5, .7, .9]}
# Init the Model
lda = LatentDirichletAllocation()
# Init Grid Search Class
model = GridSearchCV(lda, param_grid=search_params)
# Do the Grid Search
model.fit(data_vectorized)
建议的最佳模型:3
这是正常的还是只发生在我身上?
这可能是什么原因?
完整代码很长,所以我没有在这里提供,但如果需要,我可以提供。
提前致谢。
【问题讨论】:
标签: scikit-learn python-3.7 lda topic-modeling gridsearchcv