Upload 4 files
Browse files- eda.py +37 -0
- prediction.py +55 -0
- requirements.txt +6 -0
- sentiments_filtered.csv +0 -0
eda.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import seaborn as sns
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
import plotly.express as px
|
6 |
+
|
7 |
+
|
8 |
+
def run():
|
9 |
+
# title
|
10 |
+
st.title('Are you ok today?')
|
11 |
+
|
12 |
+
# sub header
|
13 |
+
st.subheader('I did analysis for you!')
|
14 |
+
|
15 |
+
# lines
|
16 |
+
st.markdown('---')
|
17 |
+
|
18 |
+
# show dataframe
|
19 |
+
df = pd.read_csv('sentiments_filtered.csv')
|
20 |
+
st.dataframe(df)
|
21 |
+
|
22 |
+
# figure plot
|
23 |
+
st.write('#### Plot distribution of sentiments')
|
24 |
+
fig = plt.figure(figsize=(15, 5))
|
25 |
+
sns.countplot(x='sentiment', data=df)
|
26 |
+
st.pyplot(fig)
|
27 |
+
|
28 |
+
# histogram of word cloud
|
29 |
+
st.write('#### Histogram Plot')
|
30 |
+
option = st.selectbox('Choose column: ', ('text', 'sentiment'))
|
31 |
+
fig = plt.figure(figsize=(15, 5))
|
32 |
+
sns.histplot(df[option], bins=30, kde=True)
|
33 |
+
st.pyplot(fig)
|
34 |
+
|
35 |
+
|
36 |
+
if __name__ == '__main__':
|
37 |
+
run()
|
prediction.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from tensorflow.keras.models import load_model
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
model = load_model('/Users/wismaeka/Documents/ds/p2-ftds033-rmt-g7-wismaeka')
|
6 |
+
|
7 |
+
|
8 |
+
def run():
|
9 |
+
st.title('How are you feeling today?')
|
10 |
+
st.write('This is a simple web app to predict sentiment of a text using deep learning. Input your feeling below to get the prediction.')
|
11 |
+
st.write('Trust me, I have analyzed it for you!')
|
12 |
+
|
13 |
+
text = st.text_input('Text', 'I feel so sad today')
|
14 |
+
|
15 |
+
def convert_to_label(pred):
|
16 |
+
if pred == 0:
|
17 |
+
return 'Normal'
|
18 |
+
elif pred == 1:
|
19 |
+
return 'Suicidal'
|
20 |
+
elif pred == 2:
|
21 |
+
return 'Anxiety'
|
22 |
+
elif pred == 3:
|
23 |
+
return 'Depression'
|
24 |
+
elif pred == 4:
|
25 |
+
return 'Stress'
|
26 |
+
elif pred == 5:
|
27 |
+
return 'Bipolar'
|
28 |
+
elif pred == 6:
|
29 |
+
return 'Personality Disorder'
|
30 |
+
else:
|
31 |
+
return 'Unknown'
|
32 |
+
|
33 |
+
if st.button("Predict Your Feeling"):
|
34 |
+
prediction = model.predict(text)
|
35 |
+
label = convert_to_label(prediction)
|
36 |
+
if label == 'Normal':
|
37 |
+
st.success('Hi! Keep up the good work! You are feeling Okay today.')
|
38 |
+
elif label == 'Suicidal':
|
39 |
+
st.error('Hi! I detect you are feeling Suicidal. Please seek help.')
|
40 |
+
elif label == 'Anxiety':
|
41 |
+
st.error('Hi! I detect you are feeling Anxious. You may want to talk to someone.')
|
42 |
+
elif label == 'Depression':
|
43 |
+
st.error('Hi! I detect you are feeling Depressed. Please seek help.')
|
44 |
+
elif label == 'Stress':
|
45 |
+
st.error('Hi! I detect you are feeling Stressed. Please take a break.')
|
46 |
+
elif label == 'Bipolar':
|
47 |
+
st.error('Hi! I detect you are feeling Bipolar. Please seek help.')
|
48 |
+
elif label == 'Personality Disorder':
|
49 |
+
st.error('Hi! I detect you are having Personality Disorder. Please seek help.')
|
50 |
+
else:
|
51 |
+
st.error('Hi! I cannot detect your feeling. Please try again.')
|
52 |
+
|
53 |
+
|
54 |
+
if __name__ == '__main__':
|
55 |
+
run()
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit==1.36.0
|
2 |
+
plotly==5.22.0
|
3 |
+
seaborn==0.13.2
|
4 |
+
pandas==2.2.2
|
5 |
+
matplotlib==3.9.1
|
6 |
+
tensorflow==2.6.0
|
sentiments_filtered.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|