为什么Sklearn LDA主题模型总是建议(选择)主题最少的主题模型?

问题描述 投票:0回答:1

我正在对文本数据进行主题建模(大约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
1个回答
0
投票

我只是说,对于您的数据,三个主题比五个主题更好。您没有让模型有机会测试在第一组测试中三个主题是否合适。因此,您得到的答案是选择[5、7、10、12、15、18、20],那么5是最好的。

© www.soinside.com 2019 - 2024. All rights reserved.