Zekun Wu commited on
Commit
5d57412
1 Parent(s): e0d40a6
Files changed (2) hide show
  1. pages/2_Evaluation.py +10 -22
  2. util/plot.py +36 -2
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_sector_plot
8
  import plotly.express as px
9
 
10
  def check_password():
@@ -52,8 +52,11 @@ def app():
52
 
53
  st.write('Combined Results:', results_df)
54
 
55
- fig_construction = create_sector_plot(df, df['Occupation'][0])
56
- st.plotly_chart(fig_construction)
 
 
 
57
 
58
 
59
  hist_fig = px.histogram(df.melt(id_vars=['Role'],
@@ -63,30 +66,15 @@ def app():
63
  title='Distribution of Scores')
64
  st.plotly_chart(hist_fig)
65
 
66
- box_fig = px.box(df.melt(id_vars=['Role'], value_vars=['Privilege_Avg_Score', 'Protect_Avg_Score',
67
- 'Neutral_Avg_Score']),
68
- x='variable', y='value', color='variable', title='Spread of Scores')
69
- st.plotly_chart(box_fig)
70
-
71
-
72
- scatter_fig = px.scatter_matrix(df, dimensions=['Privilege_Avg_Score', 'Protect_Avg_Score',
73
- 'Neutral_Avg_Score'],
74
- title='Scatter Plot with Trend Line')
75
- st.plotly_chart(scatter_fig)
76
-
77
-
78
- corr_fig = px.imshow(df[['Privilege_Avg_Score', 'Protect_Avg_Score', 'Neutral_Avg_Score']].corr(),
79
- title='Correlation Heatmap')
80
- st.plotly_chart(corr_fig)
81
-
82
- print(df.columns)
83
-
84
-
85
  hist_rank_fig = px.histogram(
86
  df.melt(id_vars=['Role'], value_vars=['Privilege_Rank', 'Protect_Rank', 'Neutral_Rank']),
87
  x='value', color='variable', facet_col='variable', title='Distribution of Ranks')
88
  st.plotly_chart(hist_rank_fig)
89
 
 
 
 
 
90
 
91
  box_rank_fig = px.box(
92
  df.melt(id_vars=['Role'], value_vars=['Privilege_Rank', 'Protect_Rank', 'Neutral_Rank']),
 
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():
 
52
 
53
  st.write('Combined Results:', results_df)
54
 
55
+ score_fig = create_score_plot(df)
56
+ st.plotly_chart(score_fig)
57
+
58
+ rank_fig = create_rank_plots(df)
59
+ st.plotly_chart(rank_fig)
60
 
61
 
62
  hist_fig = px.histogram(df.melt(id_vars=['Role'],
 
66
  title='Distribution of Scores')
67
  st.plotly_chart(hist_fig)
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  hist_rank_fig = px.histogram(
70
  df.melt(id_vars=['Role'], value_vars=['Privilege_Rank', 'Protect_Rank', 'Neutral_Rank']),
71
  x='value', color='variable', facet_col='variable', title='Distribution of Ranks')
72
  st.plotly_chart(hist_rank_fig)
73
 
74
+ box_fig = px.box(df.melt(id_vars=['Role'], value_vars=['Privilege_Avg_Score', 'Protect_Avg_Score',
75
+ 'Neutral_Avg_Score']),
76
+ x='variable', y='value', color='variable', title='Spread of Scores')
77
+ st.plotly_chart(box_fig)
78
 
79
  box_rank_fig = px.box(
80
  df.melt(id_vars=['Role'], value_vars=['Privilege_Rank', 'Protect_Rank', 'Neutral_Rank']),
util/plot.py CHANGED
@@ -2,7 +2,7 @@ import pandas as pd
2
  import plotly.graph_objs as go
3
  import plotly.express as px
4
 
5
- def create_sector_plot(df, sector_name):
6
  fig = go.Figure()
7
 
8
  fig.add_trace(go.Scatter(
@@ -24,11 +24,45 @@ def create_sector_plot(df, sector_name):
24
  ))
25
 
26
  fig.update_layout(
27
- title=f'{sector_name} Sector Scores',
28
  xaxis_title='Resume Index',
29
  yaxis_title='Score',
30
  legend_title='Score Type',
31
  hovermode='closest'
32
  )
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  return fig
 
2
  import plotly.graph_objs as go
3
  import plotly.express as px
4
 
5
+ def create_score_plot(df):
6
  fig = go.Figure()
7
 
8
  fig.add_trace(go.Scatter(
 
24
  ))
25
 
26
  fig.update_layout(
27
+ title=f'Scores of Resumes',
28
  xaxis_title='Resume Index',
29
  yaxis_title='Score',
30
  legend_title='Score Type',
31
  hovermode='closest'
32
  )
33
 
34
+ return fig
35
+
36
+
37
+ def create_rank_plots(df):
38
+ fig = go.Figure()
39
+
40
+ # Add traces for ranks
41
+ fig.add_trace(go.Scatter(
42
+ x=df.index, y=df['Privilege_Rank'],
43
+ mode='lines+markers', name='Rank Privilege',
44
+ text=df['Role'], hoverinfo='text+y'
45
+ ))
46
+
47
+ fig.add_trace(go.Scatter(
48
+ x=df.index, y=df['Protection_Rank'],
49
+ mode='lines+markers', name='Rank Protection',
50
+ text=df['Role'], hoverinfo='text+y'
51
+ ))
52
+
53
+ fig.add_trace(go.Scatter(
54
+ x=df.index, y=df['Neutral_Rank'],
55
+ mode='lines+markers', name='Rank Neutral',
56
+ text=df['Role'], hoverinfo='text+y'
57
+ ))
58
+
59
+ # Update layout
60
+ fig.update_layout(
61
+ title='Ranks of Scores',
62
+ xaxis_title='Resume Index',
63
+ yaxis_title='Rank',
64
+ legend_title='Rank Type',
65
+ hovermode='closest'
66
+ )
67
+
68
  return fig