Zekun Wu commited on
Commit
8e2d7d0
1 Parent(s): 538a197
Files changed (2) hide show
  1. pages/2_Evaluation.py +4 -1
  2. util/plot.py +83 -1
pages/2_Evaluation.py CHANGED
@@ -4,7 +4,7 @@ import streamlit as st
4
  import pandas as pd
5
  from io import StringIO
6
  from util.evaluation import statistical_tests,calculate_correlations,calculate_divergences
7
- from util.plot import create_score_plot,create_rank_plots
8
  import plotly.express as px
9
 
10
  def check_password():
@@ -81,6 +81,9 @@ def app():
81
  x='variable', y='value', color='variable', title='Spread of Ranks')
82
  st.plotly_chart(box_rank_fig)
83
 
 
 
 
84
  st.download_button(
85
  label="Download Evaluation Results",
86
  data=results_df.to_csv(index=False).encode('utf-8'),
 
4
  import pandas as pd
5
  from io import StringIO
6
  from util.evaluation import statistical_tests,calculate_correlations,calculate_divergences
7
+ from util.plot import create_score_plot,create_rank_plots,create_correlation_heatmaps
8
  import plotly.express as px
9
 
10
  def check_password():
 
81
  x='variable', y='value', color='variable', title='Spread of Ranks')
82
  st.plotly_chart(box_rank_fig)
83
 
84
+ corr_fig = create_correlation_heatmaps(df)
85
+ st.plotly_chart(corr_fig)
86
+
87
  st.download_button(
88
  label="Download Evaluation Results",
89
  data=results_df.to_csv(index=False).encode('utf-8'),
util/plot.py CHANGED
@@ -65,4 +65,86 @@ def create_rank_plots(df):
65
  hovermode='closest'
66
  )
67
 
68
- return fig
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  hovermode='closest'
66
  )
67
 
68
+ return fig
69
+
70
+
71
+ def create_correlation_heatmaps(df):
72
+ scores_df = df[['Privilege_Avg_Score', 'Protect_Avg_Score', 'Neutral_Avg_Score']]
73
+ ranks_df = df[['Privilege_Rank', 'Protect_Rank', 'Neutral_Rank']]
74
+
75
+ # Pearson correlation
76
+ scores_corr_pearson = scores_df.corr(method='pearson')
77
+ ranks_corr_pearson = ranks_df.corr(method='pearson')
78
+
79
+ # Spearman correlation
80
+ scores_corr_spearman = scores_df.corr(method='spearman')
81
+ ranks_corr_spearman = ranks_df.corr(method='spearman')
82
+
83
+ # Kendall Tau correlation
84
+ scores_corr_kendall = scores_df.corr(method='kendall')
85
+ ranks_corr_kendall = ranks_df.corr(method='kendall')
86
+
87
+ # Plotting the heatmaps
88
+ fig = go.Figure()
89
+
90
+ fig.add_trace(go.Heatmap(
91
+ z=scores_corr_pearson.values,
92
+ x=scores_corr_pearson.columns,
93
+ y=scores_corr_pearson.index,
94
+ colorscale='Viridis',
95
+ showscale=True,
96
+ name='Scores Pearson Correlation'
97
+ ))
98
+
99
+ fig.add_trace(go.Heatmap(
100
+ z=ranks_corr_pearson.values,
101
+ x=ranks_corr_pearson.columns,
102
+ y=ranks_corr_pearson.index,
103
+ colorscale='Viridis',
104
+ showscale=True,
105
+ name='Ranks Pearson Correlation'
106
+ ))
107
+
108
+ fig.add_trace(go.Heatmap(
109
+ z=scores_corr_spearman.values,
110
+ x=scores_corr_spearman.columns,
111
+ y=scores_corr_spearman.index,
112
+ colorscale='Cividis',
113
+ showscale=True,
114
+ name='Scores Spearman Correlation'
115
+ ))
116
+
117
+ fig.add_trace(go.Heatmap(
118
+ z=ranks_corr_spearman.values,
119
+ x=ranks_corr_spearman.columns,
120
+ y=ranks_corr_spearman.index,
121
+ colorscale='Cividis',
122
+ showscale=True,
123
+ name='Ranks Spearman Correlation'
124
+ ))
125
+
126
+ fig.add_trace(go.Heatmap(
127
+ z=scores_corr_kendall.values,
128
+ x=scores_corr_kendall.columns,
129
+ y=scores_corr_kendall.index,
130
+ colorscale='Inferno',
131
+ showscale=True,
132
+ name='Scores Kendall Correlation'
133
+ ))
134
+
135
+ fig.add_trace(go.Heatmap(
136
+ z=ranks_corr_kendall.values,
137
+ x=ranks_corr_kendall.columns,
138
+ y=ranks_corr_kendall.index,
139
+ colorscale='Inferno',
140
+ showscale=True,
141
+ name='Ranks Kendall Correlation'
142
+ ))
143
+
144
+ # Update layout
145
+ fig.update_layout(
146
+ title='Correlation Heatmaps',
147
+ xaxis_nticks=36
148
+ )
149
+
150
+ return fig