cuteharrie commited on
Commit
81df020
1 Parent(s): 998c037

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -19,6 +19,8 @@ import matplotlib.pyplot as plt
19
  import seaborn as sns
20
  import ast
21
 
 
 
22
 
23
  # Load the model
24
  def load_model():
@@ -110,7 +112,23 @@ if sidebar_selection == "Ratings Prediction":
110
  # Check if the submit button is clicked and the input is not empty
111
  if submit_button and ratings_review:
112
  rating_pred = ratings(ratings_review)
113
- st.write(f"The predicted average rating for a product with the list of reviews above is: {rating_pred}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  elif submit_button:
115
  # Display a message if the submit button is clicked but no review is provided
116
  st.write("Please enter a review to get a prediction.")
 
19
  import seaborn as sns
20
  import ast
21
 
22
+ nltk.download('stopwords')
23
+ nltk.download('wordnet')
24
 
25
  # Load the model
26
  def load_model():
 
112
  # Check if the submit button is clicked and the input is not empty
113
  if submit_button and ratings_review:
114
  rating_pred = ratings(ratings_review)
115
+ def get_rating_category(rating):
116
+ if rating < 2.0:
117
+ return "between 1 and 2 which is Very Low"
118
+ elif rating < 3.0:
119
+ return "between 2 and 3 which is Low"
120
+ elif rating < 4.0:
121
+ return "between 3 and 4 which is Medium"
122
+ elif rating < 5.0:
123
+ return "between 4 and 5 which is High"
124
+ else:
125
+ return "5 which is Very High"
126
+
127
+ # Determine the rating category
128
+ rating_category = get_rating_category(rating_pred)
129
+
130
+ # Display the result
131
+ st.write(f"Based on the list of reviews provided, your average rating falls {rating_category}.")
132
  elif submit_button:
133
  # Display a message if the submit button is clicked but no review is provided
134
  st.write("Please enter a review to get a prediction.")