问题遇到的现象和发生背景
pyldavis可视化运行结束后报错PicklingError: Can't pickle <joblib.externals.cloudpickle.cloudpickle._empty_cell_value object at 0x00000154CA689630>: it's not the same object as joblib.externals.cloudpickle.cloudpickle._empty_cell_value
问题相关代码,请勿粘贴截图
构建文本集
texts = [doc1]
词性标注条件
flags = ('n', 'nr', 'ns', 'nt', 'eng', 'v', 'd','vn','vd')
停用词表
stopwords = open('C:\Users\ASUS\Desktop\stop_words.txt',"r").read()
分词
words_ls = []
for text in texts:
# 采用jieba进行分词
words = [word.word for word in jp.cut(text) if word.flag in flags and word.word not in stopwords]
words_ls.append(words)
构造词典
dictionary = Dictionary(words_ls)
基于词典,使【词】→【稀疏向量】,并将向量放入列表,形成【稀疏向量集】
corpus = [dictionary.doc2bow(words) for words in words_ls]
lda模型,num_topics设置主题的个数
lda = LdaModel(corpus=corpus, id2word=dictionary, num_topics=5, random_state=100, iterations=50)
U_Mass Coherence
ldaCM = CoherenceModel(model=lda, corpus=corpus, dictionary=dictionary, coherence='u_mass')
打印所有主题,每个主题显示10个词
for topic in lda.print_topics(num_words=6):
print(topic)
data = pyLDAvis.gensim.prepare(lda,corpus,dictionary)
显示图形
pyLDAvis.show(data)
运行结果及报错内容
File "C:\Users\ASUS\Anaconda3\lib\pickle.py", line 927, in save_global
(obj, module_name, name))
PicklingError: Can't pickle <joblib.externals.cloudpickle.cloudpickle._empty_cell_value object at 0x00000154CA689630>: it's not the same object as joblib.externals.cloudpickle.cloudpickle._empty_cell_value