StockSensation icon indicating copy to clipboard operation
StockSensation copied to clipboard

个股相关词云展示有问题

Open shaoshoutianheyu opened this issue 6 years ago • 2 comments

感谢大家,我发现词云展示有点问题,不知道什么原因? 是因为代码如下: def wordcloudResult(request): return render(request,"wordcloudResult.html")

词云的数据需要单独计算出来吗? @LinLidi 希望给予回复

shaoshoutianheyu avatar Feb 12 '19 09:02 shaoshoutianheyu

Hi,@shaoshoutianheyu ,感谢关注,词云的模型采用纯粹的word2vec进行模型预测,因此没有对数据进行持久化存储,且词云图在官方的echarts插件中已经被移除,需要通过pyecharts来做单独渲染,一个临时的解决办法,代码如下:

import gensim from pyecharts import WordCloud sentences = gensim.models.word2vec.LineSentence('segwords_m.txt') model = gensim.models.Word2Vec(sentences, size=200) model.save("segwords_m.model") model = gensim.models.word2vec.Word2Vec.load("segwords_m.model") word = model.most_similar('股票名称',topn=10) name = [] value = [] for i in word: name.append(i[0]) value.append(i[1]) wordcloud = WordCloud(width=1300, height=620) wordcloud.add("", name, value, word_size_range=[20, 100]) wordcloud.render()

祝好

LinLidi avatar Feb 13 '19 14:02 LinLidi

为什么我运行起来超级卡呢

haddiss avatar Apr 24 '19 07:04 haddiss