menikev commited on
Commit
ecc5710
1 Parent(s): 49b4d85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -50,6 +50,7 @@ channel_filter = st.sidebar.multiselect('Select Channel', options=channel_option
50
  sentiment_filter = st.sidebar.multiselect('Select Sentiment', options=sentiment_options, default=sentiment_options)
51
  discrimination_filter = st.sidebar.multiselect('Select Discrimination', options=discrimination_options, default=discrimination_options)
52
 
 
53
  # Apply filters
54
  df_filtered = df[(df['Domain'].isin(domain_filter)) &
55
  (df['Channel'].isin(channel_filter)) &
@@ -76,9 +77,14 @@ def create_gender_ethnicity_distribution_chart(df):
76
 
77
  # Visualization for Sentiment Distribution Across Domains
78
  def create_sentiment_distribution_chart(df):
79
- df['Discrimination'] = df['Discrimination'].replace({"Non Discriminative": "Non-Discriminative"}) # Assuming typo in the original script
80
  domain_counts = df.groupby(['Domain', 'Sentiment']).size().reset_index(name='counts')
81
- fig = px.bar(domain_counts, x='Domain', y='counts', color='Sentiment', title="Sentiment Distribution Across Domains", barmode='stack')
 
 
 
 
 
 
82
  fig.update_layout(margin=dict(l=20, r=20, t=50, b=20), xaxis_title="Domain", yaxis_title="Counts", font=dict(size=10))
83
  return fig
84
 
 
50
  sentiment_filter = st.sidebar.multiselect('Select Sentiment', options=sentiment_options, default=sentiment_options)
51
  discrimination_filter = st.sidebar.multiselect('Select Discrimination', options=discrimination_options, default=discrimination_options)
52
 
53
+
54
  # Apply filters
55
  df_filtered = df[(df['Domain'].isin(domain_filter)) &
56
  (df['Channel'].isin(channel_filter)) &
 
77
 
78
  # Visualization for Sentiment Distribution Across Domains
79
  def create_sentiment_distribution_chart(df):
 
80
  domain_counts = df.groupby(['Domain', 'Sentiment']).size().reset_index(name='counts')
81
+ domain_counts = domain_counts.sort_values('counts')
82
+
83
+ # Reverse the color scheme
84
+ color_map = {'Negative': 'red', 'Positive': 'blue', 'Neutral': 'lightblue'}
85
+
86
+ fig = px.bar(domain_counts, x='Domain', y='counts', color='Sentiment', color_discrete_map=color_map,
87
+ title="Sentiment Distribution Across Domains", barmode='stack')
88
  fig.update_layout(margin=dict(l=20, r=20, t=50, b=20), xaxis_title="Domain", yaxis_title="Counts", font=dict(size=10))
89
  return fig
90