Kurkur99 commited on
Commit
f34c5f4
1 Parent(s): af8095b

Upload 8 files

Browse files
Files changed (8) hide show
  1. app.py +22 -0
  2. eda.py +23 -0
  3. my_model.h5 +3 -0
  4. prediction.py +17 -0
  5. preprocessing_data.pkl +3 -0
  6. requirements.txt +23 -0
  7. threads_reviews.csv +0 -0
  8. tokenizer.pkl +3 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from eda import display_eda
4
+ from prediction import predict_and_strategy
5
+
6
+ # Load the data
7
+ data = pd.read_csv('threads_reviews.csv')
8
+
9
+ st.title("Sentiment Analysis and Business Strategy")
10
+
11
+ # EDA Section
12
+ st.header("Exploratory Data Analysis")
13
+ if st.checkbox("Show EDA", False): # Checkbox to toggle EDA display
14
+ display_eda(data)
15
+
16
+ # Prediction Section
17
+ st.header("Prediction")
18
+ user_input = st.text_area("Enter text for sentiment analysis:", "")
19
+ if st.button("Analyze"):
20
+ sentiment, strategy = predict_and_strategy(user_input)
21
+ st.write(f"Sentiment: {sentiment}")
22
+ st.write(f"Strategy: {strategy}")
eda.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ from wordcloud import WordCloud
5
+
6
+ def display_eda(data):
7
+ # Distribution of sentiments
8
+ st.subheader("Distribution of Sentiments")
9
+ sentiment_counts = data['sentiment'].value_counts()
10
+ st.bar_chart(sentiment_counts)
11
+
12
+ # Word cloud for each sentiment
13
+ st.subheader("Word Clouds for Sentiments")
14
+ sentiments = data['sentiment'].unique()
15
+ for sentiment in sentiments:
16
+ st.write(f"Word Cloud for {sentiment}")
17
+ subset = data[data['sentiment'] == sentiment]
18
+ text = " ".join(review for review in subset['processed_review'])
19
+ wordcloud = WordCloud(max_words=100, background_color="white").generate(text)
20
+ plt.figure()
21
+ plt.imshow(wordcloud, interpolation="bilinear")
22
+ plt.axis("off")
23
+ st.pyplot()
my_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8e57bd45f6afda98272478433c8df6e4ed7a2d19b41c9f8b4c8de54ff0da7264
3
+ size 3911040
prediction.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ nlp = pipeline("sentiment-analysis")
4
+
5
+ def predict_and_strategy(text):
6
+ result = nlp(text)
7
+ sentiment = result[0]['label']
8
+
9
+ # Provide strategy based on sentiment
10
+ if sentiment == "POSITIVE":
11
+ strategy = "Engage with these customers to make them brand ambassadors."
12
+ elif sentiment == "NEUTRAL":
13
+ strategy = "Try to find out what's missing and engage more with these customers."
14
+ else:
15
+ strategy = "Address the concerns of these customers immediately."
16
+
17
+ return sentiment, strategy
preprocessing_data.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f2a2425763e25b1ad53362b6c2fe6b9833611484f11058b70d609ef0c18e07e
3
+ size 90
requirements.txt ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Basic libraries
2
+ numpy
3
+ pandas
4
+ matplotlib
5
+ seaborn
6
+
7
+ # Machine Learning and Deep Learning
8
+ tensorflow
9
+ keras
10
+ scikit-learn
11
+
12
+ # Natural Language Processing
13
+ transformers # from Hugging Face
14
+ tokenizers # often used alongside transformers
15
+
16
+ # Web App
17
+ streamlit
18
+
19
+ # Miscellaneous
20
+ requests
21
+
22
+ # Depending on your specific needs or the deployment platform, you might also need:
23
+ gunicorn # WSGI HTTP Server for UNIX, often used for deploying Flask and Streamlit apps on platforms like Heroku
threads_reviews.csv ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ea16cd2ff6a9a38106463fb4e07bafbd57ed8180cac5d7cd07a4153eb1effd7
3
+ size 574685