sorted对字典进行排序
https://blog.csdn.net/u013193903/article/details/81096367
myprofile
= user_profiles
[-1479311724257856983]
print(myprofile
.shape
)
pd
.DataFrame
(sorted(zip(tfidf_feature_names
,
user_profiles
[-1479311724257856983].flatten
().tolist
()), key
=lambda x
: -x
[1])[:20],
columns
=['token', 'relevance'])
##tfidf_feature_names获取词袋模型中的所有词语 这里的-x[1] z正常是升序排列 加一个负号就变成逆序排列了
tfidf_feature_names
= vectorizer
.get_feature_names
()