下面是主题文档概率矩阵的数据框,第一行是文本文件的名称。在
1 2 ... 80 81
0 778.txt 856.txt ... 831.txt 850.txt
1 0.002735042735042732 0.0054700854700846634 ... 0.01641025640567632 4.2490294446698094e-09
2 2.146512500161246e-28 8.006312700113502e-16 ... 4.580074538571013e-12 0.02017093592191074
其中,值为(0.0,1.0)的列0表示主题1和主题2的索引分别。之后对每列排序(decsending)
^{pr2}$我得到以下输出
^{3}$我想显示每个文档的主题文档排名矩阵,例如
id topic-rank
778 1, 0
856 1, 0
835 0, 1
786 0, 1
...
831 0, 1
850 1, 0
对于id为1的文档,我分配了1,0,因为主题2的概率大于主题1,依此类推。 怎么做呢? 已编辑问题的示例数据这些只是dataframe的head()值。在
id text
0 15623 Y:\n1. Ran preliminary experiments to set para...
1 15625 Scrum Minutes- Hersheys\nPresent: Eyob, Masres...
2 15627 Present: Eyob, Masresha, Zelalem\nhersheys:\n...
3 15628 **********************************************...
4 15629 Scrum Minutes- Hersheys\nPresent: Eyob, Masres...
使用argsort with descending ordering表示具有数据帧构造函数的位置:
编辑:
^{pr2}$编辑1:
相关问题 更多 >
编程相关推荐