#!/usr/bin/env python # coding: utf-8 # # Installation # In[ ]: # run this cell to install pycaret in Google Colab # !pip install pycaret # In[ ]: # If you are using Jupyter notebook, you can pip install pycaret using jupyter notebook or command line # pip install pycaret # In[1]: from pycaret.utils import version version() # In[ ]: # only run this cell if you are using google colab # from pycaret.utils import enable_colab # enable_colab() # # 1. Importing Dataset # In[2]: from pycaret.datasets import get_data data = get_data('kiva') # In[3]: data.en[0] # In[4]: data = data.head(1000) # # 2. Setting up Environment # In[5]: from pycaret.nlp import * nlp1 = setup(data, target='en', session_id=786) # # 3. Train Topic Model # In[10]: lda = create_model('lda') # In[11]: print(lda) # In[12]: nmf = create_model('nmf') # In[13]: print(nmf) # # 4. Analyze Trained Model # In[14]: plot_model() # In[15]: plot_model(lda) # In[16]: plot_model(lda, plot = 'tsne') # In[17]: plot_model(nmf, plot = 'tsne') # In[18]: evaluate_model(lda) # # 5. Assign Labels / Predict on new data # In[19]: results = assign_model(lda) results.head() # # Learning Resources: # - PyCaret NLP Module : https://www.pycaret.org/nlp # - NLP Tutorial (Level Beginner) : https://www.pycaret.org/nlp101 # - NLP Tutorial (Level Intermediate) : https://www.pycaret.org/nlp102 # - Topic Modeling in PyCaret (Video Tutorial) : https://www.youtube.com/watch?v=G6ShuoM3T1M