<jupyter_start><jupyter_text>anticipation for:topic0: Roth IRA and traditional IRAtopic1: tax and help with tax implicationtopic2: funds and saving accountstopic3: paying debts on cars and houses.<jupyter_code>#n-gram for fear
count_df2=count_2gram(fear_df['selftext'])
count_df2.head(20)
#topic modeling for fear
fear_df=df[df['label']=='fear']

count_df1=tfidfvectorizer(fear_df)
model1=nmf_topic(3,count_df1)
topic1=pd.DataFrame({'Topic 0':top_words(count_df1, model1, 0, 15),
                   'Topic 1':top_words(count_df1, model1, 1, 15),
                   'Topic 2':top_words(count_df1, model1, 2, 15)
                   })
topic1<jupyter_output><empty_output><jupyter_text>fear for:topic0:credit card debttopic1:car payment and student loan paymenttopic3:roth ira<jupyter_code>sadness_df=df[df['label']=='sadness']
#n-grams for sadness
count_df2=count_2gram(sadness_df['selftext'])
count_df2.head(20)
#topic modeling for sadness
sadness_df=df[df['label']=='sadness']

count_df1=tfidfvectorizer(sadness_df)
model1=nmf_topic(4,count_df1)
topic1=pd.DataFrame({'Topic 0':top_words(count_df1, model1, 0, 15),
                   'Topic 1':top_words(count_df1, model1, 1, 15),
                   'Topic 2':top_words(count_df1, model1, 2, 15),
                     'Topic 3':top_words(count_df1, model1, 3, 15)                   })
topic1<jupyter_output><empty_output><jupyter_text>sadness for:topic0: credit card service and debttopic1:file tax and self-employed taxtopic2:missing payment for collection agenciestopic3:roth ira and aging<jupyter_code>joy_df=df[df['label']=='joy']

#n-grams for joy
count_df2=count_2gram(joy_df['selftext'])
count_df2.head(20)
#topic modeling for sadness

count_df1=tfidfvectorizer(joy_df)
model1=nmf_topic(5,count_df1)
topic1=pd.DataFrame({'Topic 0':top_words(count_df1, model1, 0, 15),
                   'Topic 1':top_words(count_df1, model1, 1, 15),
                   'Topic 2':top_words(count_df1, model1, 2, 15),
                     'Topic 3':top_words(count_df1, model1, 3, 15),
                     'Topic 4':top_words(count_df1, model1, 4, 15),
                   })
topic1<jupyter_output><empty_output><jupyter_text>joy for:topic0:make money and pay debtstopic1:age and monthly paymentstopic2:family and long-term investtopic3:job matching and roth iratopic4:investing and money saving<jupyter_code>disgust_df=df[df['label']=='disgust']

#n-grams for joy
count_df2=count_2gram(disgust_df['selftext'])
count_df2.head(20)
#topic modeling for sadness

count_df1=tfidfvectorizer(disgust_df)
model1=nmf_topic(5,count_df1)
topic1=pd.DataFrame({'Topic 0':top_words(count_df1, model1, 0, 15),
                   'Topic 1':top_words(count_df1, model1, 1, 15)
                   })
topic1<jupyter_output><empty_output><jupyter_text>disgust for:topic0: mortgage company and mortgage ratetopic1: other topics(for disgust, mortgage rates and buying house is the most obvious topic, and the other topics doesn't make strong sense)<jupyter_code>surprise_df=df[df['label']=='surprise']

#n-grams for surprise
count_df2=count_2gram(surprise_df['selftext'])
count_df2.head(20)
#topic modeling for surprise
count_df1=tfidfvectorizer(disgust_df)
model1=nmf_topic(5,count_df1)
topic1=pd.DataFrame({'Topic 0':top_words(count_df1, model1, 0, 15)})
topic1<jupyter_output><empty_output><jupyter_text>surprise for:topic0: lower mortgage rate and buy house(text labelled as surprise is not as many as those labelled other tags)<jupyter_code>anger_df=df[df['label']=='anger']

#n-grams for anger
count_df2=count_2gram(anger_df['selftext'])
count_df2.head(20)
#topic modeling for anger

count_df1=tfidfvectorizer(anger_df)
model1=nmf_topic(3,count_df1)
topic1=pd.DataFrame({'Topic 0':top_words(count_df1, model1, 0, 15),
                   'Topic 1':top_words(count_df1, model1, 1, 15),
                   'Topic 2':top_words(count_df1, model1, 2, 15)})
topic1<jupyter_output><empty_output><jupyter_text>anger for:topic0: insurance company and bankstopic1: loans and time(year ago)topic2: brokerage account(special for this sentiment)<jupyter_code>trust_df=df[df['label']=='trust']

#n-grams for trust
count_df2=count_2gram(trust_df['selftext'])
count_df2.head(20)
#topic modeling for trust

count_df1=tfidfvectorizer(trust_df)
model1=nmf_topic(5,count_df1)
topic1=pd.DataFrame({'Topic 0':top_words(count_df1, model1, 0, 15),
                   'Topic 1':top_words(count_df1, model1, 1, 15),
                   'Topic 2':top_words(count_df1, model1, 2, 15),
                    'Topic 3':top_words(count_df1, model1, 3, 15),
                    'Topic 4':top_words(count_df1, model1, 4, 15)})
topic1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12306368330464716, 'fraction_numerical': 0.050989672977624786, 'mean_word_length': 5.173970783532536, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '160193', 'license': 'MIT', 'n_tokens_mistral': 1857, 'n_tokens_neox': 1700, 'n_words': 327, 'path': 'Topic Modeling/multi-sentiment_topic modeling&ngrams-financialindependence.ipynb', 'repo_name': 'Sylviama1026/Onomy', 'size': '4648'}