hanantonio commited on
Commit
6a2eee4
·
verified ·
1 Parent(s): bd862d2

Upload prediction_compile.py

Browse files
Files changed (1) hide show
  1. src/prediction_compile.py +9 -7
src/prediction_compile.py CHANGED
@@ -120,14 +120,16 @@ def run():
120
  st.write(f"**Sentiment:** {sentiment_label} (Confidence: {confidence:.2f})")
121
 
122
  # Topic Modeling
123
- if sentiment_label == "Negative":
124
- result = topic_model_neg.transform([text])
125
- else:
126
- result = topic_model_pos.transform([text])
127
 
128
- topics, probs = result
129
- st.write(f"**Topic ID(s):** {topics}")
130
- st.write(f"**Probabilities:** {probs.tolist()}")
 
 
 
 
 
131
 
132
  if __name__ == "__main__":
133
  run()
 
120
  st.write(f"**Sentiment:** {sentiment_label} (Confidence: {confidence:.2f})")
121
 
122
  # Topic Modeling
123
+ result = topic_model_neg.transform([text]) if sentiment_label == "Negative" else topic_model_pos.transform([text])
 
 
 
124
 
125
+ if isinstance(result, tuple) and len(result) == 2:
126
+ topics, probs = result
127
+ st.write(f"**Topic ID(s):** {topics}")
128
+ st.write(f"**Probabilities:** {probs.tolist()}")
129
+ else:
130
+ topics = result
131
+ st.write(f"**Topic ID(s):** {topics}")
132
+ st.write("**Probabilities:** Not available")
133
 
134
  if __name__ == "__main__":
135
  run()