[英]Use topic modeling information from LDA as features to perform text classification through SVM
我想使用主题建模信息作为提供给svm分类器的功能来执行文本分类。 所以我想知道如何通过在数据集的训练和测试分区上执行LDA来生成主题建模功能,因为corprus会更改数据集的两个分区?
我做错了假设吗?
你能提供一个如何通过使用scikit学习来做到这一点的例子吗?
你的假设是对的。 您所做的是根据训练数据训练LDA,然后根据训练模型转换训练和测试数据。
所以你会有这样的事情:
from sklearn.decomposition import LatentDirichletAllocation as LDA
lda = LDA(n_topics=10,...)
lda.fit(training_data)
training_features = lda.transform(training_data)
testing_features = lda.transform(testing_data)
如果我是你,如果你的弓特征稀疏,我会使用numpy.hstack或scipy.hstack将LDA特征与Bag of words特征连接起来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.