python-3.x - Gensim 的 Doc2Vec most_similar 文档结果集中有限制吗?

标签 python-3.x gensim

一段时间以来,我一直在试验 doc2vec 模块。我可以训练我的模型并让训练后的模型为给定文档输出类似的文档,如下所示:

import re
modelloaded=Doc2Vec.load("model_all_doc_dm_1")

st = 'long description of a document as string'
doc = re.sub('[^a-zA-Z]', ' ', st).lower().split() 

new_doc_vec = modelloaded.infer_vector(doc)

modelloaded.docvecs.most_similar([new_doc_vec])

这很好用,给了我 10 个结果。有没有办法获得超过 10 个结果或者这是限制?

最佳答案

我找到了:

modelloaded.docvecs.most_similar([new_doc_vec], topn=N)
topn=N句柄可用于获得 10 多个结果。

关于python-3.x - Gensim 的 Doc2Vec most_similar 文档结果集中有限制吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33789541/

相关文章:

python - 如何从 gensim 0.11.1 中的 Doc2Vec 获取文档向量?

python - Python PEG 中 bitwise_or 的目的是什么?

python - 创建霍夫曼代码时如何处理 '/n' ,'/t' 和类似的 ascii 键

python3 os模块路径拼接错误?

python - 在 gensim 中使用 freebase 向量

machine-learning - KeyedVector 中的 Gensim Doc2Vec.infer_vector() 等效项

performance - Python,迭代正则表达式但在第一次匹配时停止的最快方法

python-3.x - PythonPDF : FileNotFoundError: [WinError 2] The system cannot find the file specified

visualization - 来自gensim的pyLDAvis可视化未在google colab中显示结果

python - gensim-Doc2Vec : MemoryError when training on english Wikipedia