问题描述
我正在用Python做LDA主题建模,下面是我的可视化代码:
import pyLDAvis.gensim
pyLDAvis.enable_notebook()
vis = pyLDAvis.gensim.prepare(lda_model,corpus,dictionary=lda_model.id2word)
vis
我正在寻找一种方法来将“主题间距离图”图形导出为PDF,或者至少使用matplotlib进行绘制,然后另存为pdf,有什么想法吗?
解决方法
您可以导出JSON格式的模型,然后将其与matplotlib一起使用
chrome.runtime.onMessage.addListener(function(request,sender) {
if (request.action == "getSource") {
this.pageSource = request.source;
var title = this.pageSource.match(/<title[^>]*>([^<]+)<\/title>/)[1];
alert(title)
}
});
chrome.tabs.query({ active: true,currentWindow: true },tabs => {
chrome.tabs.executeScript(
tabs[0].id,{ code: 'var s = document.documentElement.outerHTML; chrome.runtime.sendMessage({action: "getSource",source: s});' }
);
});