image_output_1.png
from wordcloud import WordCloud, STOPWORDS

import matplotlib.pyplot as plt

import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

sarcasm_df = pd.read_csv('../input/sarcasm/train-balanced-sarcasm.csv')

sarcasm_df.dropna(subset=['comment'], inplace=True)
sarcasm_df['comment'] = sarcasm_df['comment'].str.lower()
sarcasm_df['comment'] = sarcasm_df['comment'].str.replace('[^\\w\\s]', '')

sarcasm_df.created_utc = pd.to_datetime(sarcasm_df.created_utc)

plt.figure(figsize=(5,5))
ax = sns.countplot(x='label',  data= sarcasm_df)
ax.set(title = "Distribution of Classes", xlabel="Sarcasm Status", ylabel = "Total Count")
total = float(len(sarcasm_df ))
for p in ax.patches:
    height = p.get_height()
    ax.text(p.get_x()+p.get_width()/2.,
            height + 3,
            '{:1.1f}%'.format((height/total)*100),
            ha="center") 
plt.show()

sns.despine(offset=10, trim=True)

sns.despine(offset=10, trim=True)

sarcasm_df['log_comment'] = sarcasm_df['comment'].apply(lambda text: np.log1p(len(text)))

wordcloud = WordCloud(background_color='black', stopwords=STOPWORDS, max_words=200, max_font_size=100, random_state=17, width=800, height=400)
plt.figure(figsize=(12, 12))
wordcloud.generate(str(sarcasm_df.loc[sarcasm_df['label'] == 1, 'comment']))
plt.grid(b=False)
plt.imshow(wordcloud)