Archisman Karmakar commited on
Commit
4822903
·
1 Parent(s): 9bbbd14
emotionMoodtag_analysis/emotion_analysis_main.py CHANGED
@@ -291,35 +291,40 @@ def show_emotion_analysis():
291
  # st.write(f"**NEUTRAL:** {binary_predictions[1]}")
292
  # st.write(f"**POSITIVE:** {binary_predictions[2]}")
293
 
294
- # 1️⃣ **Polar Plot (Plotly)**
 
295
  emotion_moodtags = predictions_array.tolist()
296
- fig_polar = px.line_polar(
297
- pd.DataFrame(dict(r=emotion_moodtags,
298
- theta=EMOTION_MOODTAG_LABELS)),
299
- r='r', theta='theta', line_close=True
300
- )
301
- st.plotly_chart(fig_polar)
302
 
303
- # 2️⃣ **Normalized Horizontal Bar Chart (Matplotlib)**
 
 
 
 
 
 
 
 
304
  normalized_predictions = predictions_array / predictions_array.sum()
305
 
306
- fig, ax = plt.subplots(figsize=(8, 2))
307
- left = 0
308
- for i in range(len(normalized_predictions)):
309
- ax.barh(0, normalized_predictions[i], color=plt.cm.tab10(
310
- i), left=left, label=EMOTION_MOODTAG_LABELS[i])
311
- left += normalized_predictions[i]
312
-
313
- # Configure the chart
314
- ax.set_xlim(0, 1)
315
- ax.set_yticks([])
316
- ax.set_xticks(np.arange(0, 1.1, 0.1))
317
- ax.legend(loc='upper center', bbox_to_anchor=(
318
- 0.5, -0.15), ncol=len(EMOTION_MOODTAG_LABELS))
319
- plt.title("Emotion Mood-tags Prediction Distribution")
320
-
321
- # Display in Streamlit
322
- st.pyplot(fig)
 
 
323
 
324
  progress_bar.empty()
325
 
 
291
  # st.write(f"**NEUTRAL:** {binary_predictions[1]}")
292
  # st.write(f"**POSITIVE:** {binary_predictions[2]}")
293
 
294
+ col1, col2 = st.columns(2)
295
+
296
  emotion_moodtags = predictions_array.tolist()
 
 
 
 
 
 
297
 
298
+ with col1:
299
+ # 1️⃣ **Polar Plot (Plotly)**
300
+ fig_polar = px.line_polar(
301
+ pd.DataFrame(dict(r=emotion_moodtags,
302
+ theta=EMOTION_MOODTAG_LABELS)),
303
+ r='r', theta='theta', line_close=True
304
+ )
305
+ st.plotly_chart(fig_polar)
306
+
307
  normalized_predictions = predictions_array / predictions_array.sum()
308
 
309
+ with col2:
310
+ # 2️⃣ **Normalized Horizontal Bar Chart (Matplotlib)**
311
+ fig, ax = plt.subplots(figsize=(8, 2))
312
+ left = 0
313
+ for i in range(len(normalized_predictions)):
314
+ ax.barh(0, normalized_predictions[i], color=plt.cm.tab10(
315
+ i), left=left, label=EMOTION_MOODTAG_LABELS[i])
316
+ left += normalized_predictions[i]
317
+
318
+ # Configure the chart
319
+ ax.set_xlim(0, 1)
320
+ ax.set_yticks([])
321
+ ax.set_xticks(np.arange(0, 1.1, 0.1))
322
+ ax.legend(loc='upper center', bbox_to_anchor=(
323
+ 0.5, -0.15), ncol=len(EMOTION_MOODTAG_LABELS))
324
+ plt.title("Emotion Mood-tags Prediction Distribution")
325
+
326
+ # Display in Streamlit
327
+ st.pyplot(fig)
328
 
329
  progress_bar.empty()
330
 
sentimentPolarity_analysis/sentiment_analysis_main.py CHANGED
@@ -288,35 +288,41 @@ def show_sentiment_analysis():
288
  # st.write(f"**NEUTRAL:** {binary_predictions[1]}")
289
  # st.write(f"**POSITIVE:** {binary_predictions[2]}")
290
 
291
- # 1️⃣ **Polar Plot (Plotly)**
 
292
  sentiment_polarities = predictions_array.tolist()
293
- fig_polar = px.line_polar(
294
- pd.DataFrame(dict(r=sentiment_polarities,
295
- theta=SENTIMENT_POLARITY_LABELS)),
296
- r='r', theta='theta', line_close=True
297
- )
298
- st.plotly_chart(fig_polar)
299
 
300
- # 2️⃣ **Normalized Horizontal Bar Chart (Matplotlib)**
 
 
 
 
 
 
 
 
301
  normalized_predictions = predictions_array / predictions_array.sum()
302
 
303
- fig, ax = plt.subplots(figsize=(8, 2))
304
- left = 0
305
- for i in range(len(normalized_predictions)):
306
- ax.barh(0, normalized_predictions[i], color=plt.cm.tab10(
307
- i), left=left, label=SENTIMENT_POLARITY_LABELS[i])
308
- left += normalized_predictions[i]
309
-
310
- # Configure the chart
311
- ax.set_xlim(0, 1)
312
- ax.set_yticks([])
313
- ax.set_xticks(np.arange(0, 1.1, 0.1))
314
- ax.legend(loc='upper center', bbox_to_anchor=(
315
- 0.5, -0.15), ncol=len(SENTIMENT_POLARITY_LABELS))
316
- plt.title("Sentiment Polarity Prediction Distribution")
317
-
318
- # Display in Streamlit
319
- st.pyplot(fig)
 
 
 
320
 
321
  progress_bar.empty()
322
 
 
288
  # st.write(f"**NEUTRAL:** {binary_predictions[1]}")
289
  # st.write(f"**POSITIVE:** {binary_predictions[2]}")
290
 
291
+ col1, col2 = st.columns(2)
292
+
293
  sentiment_polarities = predictions_array.tolist()
 
 
 
 
 
 
294
 
295
+ with col1:
296
+ # 1️⃣ **Polar Plot (Plotly)**
297
+ fig_polar = px.line_polar(
298
+ pd.DataFrame(dict(r=sentiment_polarities,
299
+ theta=SENTIMENT_POLARITY_LABELS)),
300
+ r='r', theta='theta', line_close=True
301
+ )
302
+ st.plotly_chart(fig_polar)
303
+
304
  normalized_predictions = predictions_array / predictions_array.sum()
305
 
306
+ with col2:
307
+ # 2️⃣ **Normalized Horizontal Bar Chart (Matplotlib)**
308
+
309
+ fig, ax = plt.subplots(figsize=(8, 2))
310
+ left = 0
311
+ for i in range(len(normalized_predictions)):
312
+ ax.barh(0, normalized_predictions[i], color=plt.cm.tab10(
313
+ i), left=left, label=SENTIMENT_POLARITY_LABELS[i])
314
+ left += normalized_predictions[i]
315
+
316
+ # Configure the chart
317
+ ax.set_xlim(0, 1)
318
+ ax.set_yticks([])
319
+ ax.set_xticks(np.arange(0, 1.1, 0.1))
320
+ ax.legend(loc='upper center', bbox_to_anchor=(
321
+ 0.5, -0.15), ncol=len(SENTIMENT_POLARITY_LABELS))
322
+ plt.title("Sentiment Polarity Prediction Distribution")
323
+
324
+ # Display in Streamlit
325
+ st.pyplot(fig)
326
 
327
  progress_bar.empty()
328