LDA Topic Analysis

Summary

I am trying to build a LDA Model Training module. I have the code working in my Jupyter Notebook, was wondering if anyone could help me bring it into streamlit.

Steps to reproduce

Code snippet:

# LDA Model Training
import gensim
from pprint import pprint
# number of topics
num_topics = 10
# Build LDA model
lda_model = gensim.models.LdaMulticore(corpus=corpus,id2word=id2word,num_topics=num_topics)
# Print the Keyword in the 10 topics
#pprint(lda_model.print_topics())
doc_lda = lda_model[corpus]
st.write(lda_model.print_topics())
st.write(lda_model[corpus])

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Run the code above I tried adding in st.write functions to see if the results would print but I get no output I get a weird message that I am not sure how to address.

Explain what you expect to happen when you run the code above.

The LDA model displays the top 10 topics I have key in from code that is apart of of the bigger module.

Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.

This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:

    if __name__ == '__main__':
        freeze_support()
        ...

The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.

Debug info

  • Streamlit version: 1.15.1
  • Python version: 3.9.15
  • Using Conda
  • OS version: Windows 10
  • Browser version: Chrome

Hi @Avidan_Rothman,

Thanks for sharing your question! Please be a little more specific in terms of the unexpected behavior that you’re seeing. You mentioned “I get a weird message that I am not sure how to address.” – can you please share the error message you’re seeing?