python – 使用sсikit-learn TfIdf和gensim LDA
发布时间:2020-09-25 06:17:13 所属栏目:Python 来源:互联网
导读:我在scikit中使用了各种版本的TFIDF来学习一些文本数据的建模. vectorizer = TfidfVectorizer(min_df=1,stop_words=english) 生成的数据X采用以下格式: rowsxcolumns sparse matrix of type type numpy.float64 with xyz stored elements
我在scikit中使用了各种版本的TFIDF来学习一些文本数据的建模. vectorizer = TfidfVectorizer(min_df=1,stop_words='english') 生成的数据X采用以下格式: <rowsxcolumns sparse matrix of type '<type 'numpy.float64'>' with xyz stored elements in Compressed Sparse Row format> 我想尝试使用LDA作为减少稀疏矩阵维数的方法. lda = models.ldamodel.LdaModel(corpus=corpus,id2word=dictionary,num_topics=100) 我可以忽略scikit并按照gensim教程概述的方式,但我喜欢scikit矢量化器及其所有参数的简单性. 谢谢, G 解决方法http://radimrehurek.com/gensim/matutils.htmlclass gensim.matutils.Sparse2Corpus(sparse,documents_columns=True) Convert a matrix in scipy.sparse format into a streaming gensim corpus. (编辑:岳阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |