python - 如何在 gensim 中使用 mallet 设置主题模型的随机种子?

标签 python gensim topic-modeling mallet

我一直试图通过使用 mallet 作为 gensim 中的库来保持主题建模的输出稳定。但是,我发现 mallet 可以设置随机种子,但我在 gensim 中没有看到任何参数来设置它。

最佳答案

这刚刚添加到 ldamallet.py 包装器中

    def __init__(self, mallet_path, corpus=None, num_topics=100, alpha=50, id2word=None, workers=4, prefix=None,
             optimize_interval=0, iterations=1000, topic_threshold=0.0, random_seed=0):
    """

    Parameters
    ----------
    mallet_path : str
        Path to the mallet binary, e.g. `/home/username/mallet-2.0.7/bin/mallet`.
    corpus : iterable of iterable of (int, int), optional
        Collection of texts in BoW format.
    num_topics : int, optional
        Number of topics.
    alpha : int, optional
        Alpha parameter of LDA.
    id2word : :class:`~gensim.corpora.dictionary.Dictionary`, optional
        Mapping between tokens ids and words from corpus, if not specified - will be inferred from `corpus`.
    workers : int, optional
        Number of threads that will be used for training.
    prefix : str, optional
        Prefix for produced temporary files.
    optimize_interval : int, optional
        Optimize hyperparameters every `optimize_interval` iterations
        (sometimes leads to Java exception 0 to switch off hyperparameter optimization).
    iterations : int, optional
        Number of training iterations.
    topic_threshold : float, optional
        Threshold of the probability above which we consider a topic.
    random_seed: int, optional
        Random seed to ensure consistent results, if 0 - use system clock.

    """

关于python - 如何在 gensim 中使用 mallet 设置主题模型的随机种子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52762875/

相关文章:

python - 从字典列表中查找具有用户输入 key 的字典

python - 如何有效地将 Gensim 语料库转换为 numpy 数组(或 scipy 稀疏矩阵)?

gensim - 如何保存为gensim word2vec文件?

r - R 中随时间变化的动态主题模型/主题

nlp - 主题模型中的动态主题数

python - 为什么我不断收到 NameError : name 'PS' is not defined

python - 标准 django 表单错误消息

python - 在 Python 中有什么方法可以追加到后面吗?

python - 在 Python 中使用 gensim 在推文上运行 LDA 时出错

java - 在 Java 中使用 Mallet 在 LDA 中折叠(估计新文档的主题)