python – 使用sсikit-learn TfIdf和gensim LDA
发布时间:2020-09-25 05:56:50 所属栏目: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 – 为什么skimage.transform.rotate比PIL的Image.ro
- 如何在Python中获取类属性的定义顺序?
- Python 的名称空间和作用域
- 【Python有坑系列】列表推导和循环中的变量泄漏
- python – Django和Node – 它是如何工作的?
- Python 版的 try-with-resources——with 上下文管理器!
- python – 什么是django.utils.functional .__ proxy__对象
- python函数——根据经纬度计算距离公式的错误及修正
- python – 方法中的单个字符串或字符串列表
- python – 列出元素的比较