Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,15 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
|
4 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Streamlit app layout
|
6 |
st.title("Intelligent Customer Feedback Analyzer")
|
7 |
st.write("Analyze customer feedback for sentiment, topics, and get personalized recommendations.")
|
@@ -38,19 +46,18 @@ if uploaded_file:
|
|
38 |
for feedback_text in feedback_text_list:
|
39 |
if st.button(f'Analyze Feedback: "{feedback_text[:30]}..."'):
|
40 |
# Sentiment Analysis
|
41 |
-
sentiment = distilbert_model.predict([feedback_text])
|
42 |
sentiment_result = 'Positive' if sentiment == 1 else 'Negative'
|
43 |
st.write(f"Sentiment: {sentiment_result}")
|
44 |
|
45 |
# Topic Modeling
|
46 |
-
topics = bert_topic_model.predict([feedback_text])
|
47 |
st.write(f"Predicted Topic(s): {topics}")
|
48 |
|
49 |
# Recommendation System
|
50 |
-
recommendations = recommendation_model.predict([feedback_text])
|
51 |
st.write(f"Recommended Actions: {recommendations}")
|
52 |
else:
|
53 |
st.error("Unable to extract feedback from the file.")
|
54 |
else:
|
55 |
st.info("Please upload a feedback file to analyze.")
|
56 |
-
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import json
|
4 |
+
import joblib
|
5 |
+
import os
|
6 |
+
|
7 |
+
# Load models from the "models" folder
|
8 |
+
models_dir = "models"
|
9 |
+
# distilbert_model = joblib.load(os.path.join(models_dir, "distilbert_model.joblib"))
|
10 |
+
bert_topic_model = joblib.load(os.path.join(models_dir, "bert_topic_model.joblib"))
|
11 |
+
recommendation_model = joblib.load(os.path.join(models_dir, "recommendation_model.joblib"))
|
12 |
+
|
13 |
# Streamlit app layout
|
14 |
st.title("Intelligent Customer Feedback Analyzer")
|
15 |
st.write("Analyze customer feedback for sentiment, topics, and get personalized recommendations.")
|
|
|
46 |
for feedback_text in feedback_text_list:
|
47 |
if st.button(f'Analyze Feedback: "{feedback_text[:30]}..."'):
|
48 |
# Sentiment Analysis
|
49 |
+
sentiment = distilbert_model.predict([feedback_text])[0] # Get the first result
|
50 |
sentiment_result = 'Positive' if sentiment == 1 else 'Negative'
|
51 |
st.write(f"Sentiment: {sentiment_result}")
|
52 |
|
53 |
# Topic Modeling
|
54 |
+
topics = bert_topic_model.predict([feedback_text])[0] # Get the first topic
|
55 |
st.write(f"Predicted Topic(s): {topics}")
|
56 |
|
57 |
# Recommendation System
|
58 |
+
recommendations = recommendation_model.predict([feedback_text])[0] # Get the first recommendation
|
59 |
st.write(f"Recommended Actions: {recommendations}")
|
60 |
else:
|
61 |
st.error("Unable to extract feedback from the file.")
|
62 |
else:
|
63 |
st.info("Please upload a feedback file to analyze.")
|
|