import re
import matplotlib.pyplot as plt
p = re.compile("(-*\d+\.\d+) per-word .* (\d+\.\d+) perplexity")
matches = [p.findall(l) for l in open('gensim.log')]
matches = [m for m in matches if len(m) > 0]
tuples = [t[0] for t in matches]
perplexity = [float(t[1]) for t in tuples]
liklihood = [float(t[0]) for t in tuples]
iter = list(range(0,len(tuples)*10,10))
plt.plot(iter,liklihood,c="black")
plt.ylabel("log liklihood")
plt.xlabel("iteration")
plt.title("Topic Model Convergence")
plt.grid()
plt.savefig("convergence_liklihood.pdf")
plt.close()
您希望绘制模型拟合的收敛性是正确的。 不幸的是,根西姆似乎并没有把这件事说得很直截了当。在
以能够分析模型拟合函数的输出的方式运行模型。我想设置一个日志文件。在
在
LdaModel
中设置eval_every
参数。该值越低,绘图的分辨率就越好。然而,计算这种困惑会减慢你的拟合速度!分析日志文件并绘制绘图。在
相关问题 更多 >
编程相关推荐