dnirfana commited on
Commit
f34ca92
1 Parent(s): 4148852

Upload 6 files

Browse files
Files changed (6) hide show
  1. app.py +13 -0
  2. eda.py +33 -0
  3. prediction.py +49 -0
  4. requirements.txt +1 -0
  5. target label proportion.png +0 -0
  6. wordcloud.png +0 -0
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contents of app.py
2
+ import eda
3
+ import prediction
4
+ import streamlit as st
5
+
6
+ PAGES = {
7
+ "Exploratory Data Analysis": eda,
8
+ "Make Predictions": prediction
9
+ }
10
+ st.sidebar.title('Navigation')
11
+ selection = st.sidebar.radio("Go to", list(PAGES.keys()))
12
+ page = PAGES[selection]
13
+ page.app()
eda.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contents of `app1.py`
2
+ import streamlit as st
3
+
4
+ def app():
5
+ st.title('Exploratory Data Analysis')
6
+
7
+ st.header('Target Label Proportion')
8
+ st.image('target label proportion.png', caption='Picture 1: Target Label Proportion')
9
+ st.write('''The plot shows the distribution of user suggestions for a yes or no question. The left pie chart shows that 83.8% of users suggesting yes, while 16.2% suggesting no.
10
+ The plot also shows a class imbalance, where one class has a significantly higher proportion of data points compared to the other. In this case, it's a binary classification problem with:''')
11
+ st.write('''- **Majority Class**: This is the dominant class, represented by the larger pie slice (83.8%) who responded `Yes` in your example.''')
12
+ st.write('''- **Minority Class**: This is the smaller class, represented by the smaller pie slice (16.2%) who responded `No`.''')
13
+
14
+
15
+ st.header('Most Words Appear In Review')
16
+ st.image('wordcloud.png', caption='Picture 2: Most Words Appear In Review')
17
+ st.write('''The word cloud depicts words commonly found in skincare product reviews. Here are some of the most prominent words:''')
18
+ st.write('''- **Moisturizer**: This suggests that the reviews are about a product that hydrates the skin.''')
19
+ st.write('''- **Skin**: This is not surprising as the word cloud is about product reviews.''')
20
+ st.write('''- **Love**: People seem to really like this product!''')
21
+ st.write('''- **Dry**: This might be an indicator that the product is effective for dry skin.''')
22
+ st.write('''- **Soft**: Another positive descriptor for the product’s effect on skin.''')
23
+ st.write('''- **Cream**: This could be the type of product being reviewed.''')
24
+ st.write('''- **Face**: This again reinforces that the reviews are about a facial skin care product.''')
25
+ st.write('''- **Buy**: This indicates positive sentiment towards the product.''')
26
+ st.write('''- **Price**: People are considering the price of the product in their reviews.''')
27
+ st.write('''- **Breakout**: This suggests that some reviewers experienced irritation from the product.''')
28
+ st.write('''- **Sensitive**: This indicates that the product might not be suitable for all skin types.''')
29
+
30
+
31
+
32
+ if __name__ == '__main__':
33
+ app()
prediction.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contents of `app2.py`
2
+ import streamlit as st
3
+ import tensorflow as tf
4
+ from tensorflow.keras.models import load_model
5
+
6
+ # Function to load the model
7
+ @st.cache_data
8
+ def load_sentiment_model():
9
+ model = load_model('../model.keras')
10
+ return model
11
+
12
+ # Function to make predictions
13
+ def predict_sentiment(review_text, model):
14
+ # Perform prediction
15
+ pred = model.predict([review_text])
16
+ prediction = tf.where(pred >= 0.5, 1, 0)
17
+
18
+ # Convert tensor to a list of 1s and 0s
19
+ predictions_list = prediction.numpy().flatten().tolist()
20
+
21
+ # Replace 1 with 'Recommending' and 0 with 'Not Recommending'
22
+ predictions_recommended = ['The author recommending this product' if x == 1 else 'The author not recommending this product' for x in predictions_list]
23
+
24
+ return predictions_recommended
25
+
26
+ # Streamlit app function
27
+ def app():
28
+ st.title('Make Predictions')
29
+
30
+ # Load the model
31
+ model = load_sentiment_model()
32
+
33
+ # Text input for user
34
+ user_input = st.text_area("Enter your review:", "")
35
+
36
+ if st.button("Predict"):
37
+ if user_input:
38
+ # Display a loading message while predicting
39
+ with st.spinner('Predicting...'):
40
+ # Perform prediction
41
+ predictions = predict_sentiment(user_input, model)
42
+
43
+ # Display the prediction result
44
+ st.success(f'Prediction: {predictions[0]}')
45
+ else:
46
+ st.warning("Please enter a review.")
47
+
48
+ if __name__ == '__main__':
49
+ app()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ tensorflow == 2.15.0
target label proportion.png ADDED
wordcloud.png ADDED