Gensim LDA 相干性得分 NaN

我按照这个教程创建了一个 Gensim LDA 模型:https://www.machinelearningplus.com/nlp/topic-modeling-gensim-python/

lda_model = gensim.models.LdaMulticore(data_df['bow_corpus'], num_topics=10, id2word=dictionary, random_state=100, chunksize=100, passes=10, per_word_topics=True)

它生成了10个主题,日志困惑度为:

lda_model.log_perplexity(data_df[‘bow_corpus’]) = -5.325966117835991

但是当我运行相干性模型来计算相干性得分时,像这样:

coherence_model_lda = CoherenceModel(model=lda_model, texts=data_df['bow_corpus'].tolist(), dictionary=dictionary, coherence='c_v')with np.errstate(invalid='ignore'):    lda_score = coherence_model_lda.get_coherence()

我的 LDA 得分是 NaN。我在这里做错了什么?


回答:

已解决!相干性模型需要原始文本,而不是输入 LDA 模型的训练语料库 – 所以当我运行这个时:

coherence_model_lda = CoherenceModel(model=lda_model, texts=data_df['corpus'].tolist(), dictionary=dictionary, coherence='c_v')with np.errstate(invalid='ignore'):    lda_score = coherence_model_lda.get_coherence()

我得到了一个相干性得分为:0.462

希望这能帮助犯同样错误的其他人。谢谢!

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注