code
stringlengths
3
6.57k
topic_weight_full.append([word, i , weight, counter_full[word]])
pd.DataFrame(topic_weight_full, columns=['word', 'topic_id', 'importance', 'word_count'])
plt.subplots(3, 3, figsize=(10,6)
enumerate(axes.flatten()
ax.bar(x='word', height="word_count", data=data_frame_full.loc[data_frame_full.topic_id==i, :], color=colors[i], width=0.5, alpha=0.3, label='Word Count')
ax.twinx()
ax_twin.bar(x='word', height="importance", data=data_frame_full.loc[data_frame_full.topic_id==i, :], color=colors[i], width=0.2, label='Weights')
ax.set_ylabel('Word Count', color=colors[i])
ax_twin.set_ylim(0, 0.5)
ax.set_ylim(0, 100)
ax.set_title('Topic: ' + str(i+1)
ax.tick_params(axis='y', left=False)
ax.set_xticklabels(data_frame_full.loc[data_frame_full.topic_id==i, 'word'], rotation=90, horizontalalignment= 'center')
ax.legend(loc='upper left')
ax_twin.legend(loc='upper right')
fig.tight_layout(w_pad=2)
plt.show()
lda_pos.show_topics(formatted=False)
Counter(flatten_pos)
topic_weight_pos.append([word, i , weight, counter_pos[word]])
pd.DataFrame(topic_weight_pos, columns=['word', 'topic_id', 'importance', 'word_count'])
plt.subplots(3, 3, figsize=(10,6)
enumerate(axes.flatten()
ax.bar(x='word', height="word_count", data=data_frame_pos.loc[data_frame_pos.topic_id==i, :], color=colors[i], width=0.5, alpha=0.3, label='Word Count')
ax.twinx()
ax_twin.bar(x='word', height="importance", data=data_frame_pos.loc[data_frame_pos.topic_id==i, :], color=colors[i], width=0.2, label='Weights')
ax.set_ylabel('Word Count', color=colors[i])
ax_twin.set_ylim(0, 0.5)
ax.set_ylim(0, 100)
ax.set_title('Topic: ' + str(i+1)
ax.tick_params(axis='y', left=False)
ax.set_xticklabels(data_frame_pos.loc[data_frame_pos.topic_id==i, 'word'], rotation=90, horizontalalignment= 'center')
ax.legend(loc='upper left')
ax_twin.legend(loc='upper right')
fig.tight_layout(w_pad=2)
plt.show()
lda_neg.show_topics(formatted=False)
Counter(flatten_neg)
topic_weight_neg.append([word, i , weight, counter_neg[word]])
pd.DataFrame(topic_weight_neg, columns=['word', 'topic_id', 'importance', 'word_count'])
plt.subplots(3, 3, figsize=(10,6)
enumerate(axes.flatten()
ax.bar(x='word', height="word_count", data=data_frame_neg.loc[data_frame_neg.topic_id==i, :], color=colors[i], width=0.5, alpha=0.3, label='Word Count')
ax.twinx()
ax_twin.bar(x='word', height="importance", data=data_frame_neg.loc[data_frame_neg.topic_id==i, :], color=colors[i], width=0.2, label='Weights')
ax.set_ylabel('Word Count', color=colors[i])
ax_twin.set_ylim(0, 0.5)
ax.set_ylim(0, 100)
ax.set_title('Topic: ' + str(i+1)
ax.tick_params(axis='y', left=False)
ax.set_xticklabels(data_frame_neg.loc[data_frame_neg.topic_id==i, 'word'], rotation=90, horizontalalignment= 'center')
ax.legend(loc='upper left')
ax_twin.legend(loc='upper right')
fig.tight_layout(w_pad=2)
plt.show()
WordCloud(stopwords=stoplist, background_color='white', width=2500, height=1800, max_words=7, colormap='tab10', color_func=lambda *args, **kwargs: colors[i], prefer_horizontal=1.0)
lda_full.show_topics(formatted=False)
plt.subplots(3, 3, figsize=(10, 6)
enumerate(axes.flatten()
fig.add_subplot(ax)
dict(topics_full[i][1])
cloud.generate_from_frequencies(topic_words_full, max_font_size=300)
plt.gca()
imshow(cloud)
plt.gca()
set_title('Topic ' + str(i+1)
dict(size=10)
plt.gca()
axis('off')
plt.axis('off')
plt.tight_layout()
plt.show()
WordCloud(stopwords=stoplist, background_color='white', width=2500, height=1800, max_words=7, colormap='tab10', color_func=lambda *args, **kwargs: colors[i], prefer_horizontal=1.0)
lda_pos.show_topics(formatted=False)
plt.subplots(3, 3, figsize=(10, 6)
enumerate(axes.flatten()
fig.add_subplot(ax)
dict(topics_pos[i][1])
cloud.generate_from_frequencies(topic_words_pos, max_font_size=300)
plt.gca()
imshow(cloud)
plt.gca()
set_title('Topic ' + str(i+1)
dict(size=10)
plt.gca()
axis('off')
plt.axis('off')
plt.tight_layout()
plt.show()
WordCloud(stopwords=stoplist, background_color='white', width=2500, height=1800, max_words=7, colormap='tab10', color_func=lambda *args, **kwargs: colors[i], prefer_horizontal=1.0)
lda_neg.show_topics(formatted=False)
plt.subplots(3, 3, figsize=(10, 6)
enumerate(axes.flatten()
fig.add_subplot(ax)
dict(topics_neg[i][1])
cloud.generate_from_frequencies(topic_words_neg, max_font_size=300)
plt.gca()
imshow(cloud)
plt.gca()
set_title('Topic ' + str(i+1)