application_vnd.jupyter.stderr_output_1.png
from wordcloud import WordCloud

import matplotlib.pyplot as plt

import numpy as np # linear algebra

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

import seaborn as sns #what is seaborn

df_sample = pd.read_csv('/kaggle/input/train.csv')
df_actual = pd.read_csv('/kaggle/input/test.csv')

df_sample['length'] = np.NaN
for i in range(0, len(df_sample['text'])):
    df_sample['length'][i] = len(df_sample['text'][i])
df_sample.length = df_sample.length.astype(int)

#creating subplots to see distribution of length of tweet
sns.set_style("darkgrid");
f, (ax1, ax2) = plt.subplots(figsize=(12,6),nrows=1, ncols=2,tight_layout=True);
sns.distplot(df_sample[df_sample['target']==1]["length"],bins=30,ax=ax1);
sns.distplot(df_sample[df_sample['target']==0]["length"],bins=30,ax=ax2);
ax1.set_title('\n Distribution of length of tweet labelled Disaster\n');
ax2.set_title('\nDistribution of length of tweet labelled No Disaster\n ');
ax1.set_ylabel('Frequency');

text = ' '.join((post for post in df_sample[df_sample['target'] == 1].text))
wordcloud = WordCloud(max_font_size=90, max_words=50, background_color='white', colormap='inferno').generate(text)
plt.axis('off')

text = ' '.join((post for post in df_sample[df_sample['target'] == 0].text))
wordcloud = WordCloud(max_font_size=90, max_words=50, background_color='white', colormap='inferno').generate(text)
plt.figure(figsize=(10, 10))
plt.imshow(wordcloud, interpolation='bilinear')
plt.title('\nFrequently occuring words related to Non Disaster \n\n', fontsize=18)
plt.axis('off')
plt.show()