I'm new to using reticulate to incorporate python into my R scripts. Running basic code chunks seems to work great, but if I try to incorporate model development, I've found that my code will run endlessly without producing an error message. Hitting the interrupt button doesn't stop it and I have to force quit R and start over. Reprex:
import gensim as gensim
from gensim import corpora, models, similarities, downloader
texts = [['human', 'interface', 'computer'],
['survey', 'user', 'computer', 'system', 'response', 'time'],
['eps', 'user', 'interface', 'system'],
['system', 'human', 'system', 'eps'],
['user', 'response', 'time'],
['trees'],
['graph', 'trees'],
['graph', 'minors', 'trees'],
['graph', 'minors', 'survey']]
# Create Dictionary
id2word = gensim.corpora.Dictionary(texts)
# Create Corpus: Term Document Frequency
corpus = [id2word.doc2bow(text) for text in texts]
# Create lda model
Lda = gensim.models.ldamodel.LdaModel
ldamodel = Lda(corpus, num_topics=2, id2word = id2word, iterations=50)
# Create coherence model
cm = gensim.models.coherencemodel.CoherenceModel(model=ldamodel, texts=texts, dictionary=id2word, coherence='c_v')
#get coherence - code gets hung up here
result = cm.get_coherence()
My memory usage still shows 50% unused.
I'm using R version 4.2.3, Quarto version 1.2, and Pythin 3.10.4