Spaces:
Sleeping
Sleeping
File size: 1,007 Bytes
f4c764c 9941f6f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from wordcloud import WordCloud
import streamlit as st
# Streamlit app title
st.title(":red[Email Spam or Ham Classification]")
# Displaying the original DataFrame
st.subheader(":blue[Data Frame]")
df = pd.read_csv('spam.csv')
st.write(df)
st.subheader(':blue[Count of Each Category]')
fig, ax = plt.subplots(figsize=(10, 4))
sns.countplot(data=df, x='Category', palette="viridis", ax=ax)
ax.set_xlabel('Category')
ax.set_ylabel('Count')
st.pyplot(fig)
st.subheader(":blue[Filter 'ham' emails]")
ham_emails = df[df['Category']=='ham']
s = ' '.join(ham_emails['Message'])
obj_= WordCloud().generate(s)
fig1, ax1 = plt.subplots(figsize=(10, 5))
plt.imshow(obj_)
st.pyplot(fig1)
st.subheader(":blue[Filter 'spam' emails]")
ham_emails = df[df['Category']=='spam']
s1 = ' '.join(ham_emails['Message'])
obj1_= WordCloud().generate(s1)
fig2, ax2 = plt.subplots(figsize=(10, 5))
plt.imshow(obj1_)
st.pyplot(fig2) |