<jupyter_start><jupyter_text>Topic Modeling<jupyter_code>import pandas as pd
from data_describe.text.topic_modeling import topic_model
from sklearn.datasets import fetch_20newsgroups
categories = ['alt.atheism']
newsgroups_train = fetch_20newsgroups(subset='train', categories=categories)
df = pd.DataFrame({"text": newsgroups_train['data']})
df.head()<jupyter_output><empty_output><jupyter_text>Explicitly providing number of topics<jupyter_code>lda_model = topic_model(df.text, num_topics=2)
lda_model<jupyter_output><empty_output><jupyter_text>Guess optimal number of topics and show elbow plot<jupyter_code>%%time
lda_model = topic_model(df.text, num_topics=None, min_topics=2, max_topics=4)
lda_model
lda_model.elbow_plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10554089709762533, 'fraction_numerical': 0.009234828496042216, 'mean_word_length': 12.086206896551724, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '196139', 'license': 'Apache-2.0', 'n_tokens_mistral': 283, 'n_tokens_neox': 273, 'n_words': 44, 'path': 'examples/Topic_Modeling.ipynb', 'repo_name': 'truongc2/data-describe', 'size': '758'}