python – 使用sсikit-learn TfIdf和gensim LDA
发布时间:2020-09-25 05:48:32 所属栏目: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. (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 【Python分布式】RQ:python的简单任务队列
- 如何在带有错误栏的条形图中绘制pandas数据帧的特定行和列(
- 如何在Python 3.1中将字符串转换为缓冲区?
- python – 了解matplotlib xticks语法
- .net – 一旦线程启动,我应该保持对线程的引用吗?
- 【Python】【并行计算】Python的GIL是什么鬼,多线程性能究
- Python / Scipy – 将optimize.curve_fit的sigma实现到opti
- AIX上的Python:我的选择是什么?
- python – 多进程还是多线程? – 并行化数百万次迭代的简单
- java如何实现python的urllib.quote(str,safe=/)