prakharg24 commited on
Commit
91d4827
·
verified ·
1 Parent(s): 6726747

Update my_pages/rashomon_effect.py

Browse files
Files changed (1) hide show
  1. my_pages/rashomon_effect.py +15 -3
my_pages/rashomon_effect.py CHANGED
@@ -29,8 +29,8 @@ def render():
29
 
30
  st.markdown("---")
31
 
32
- income = np.array([80, 85, 97, 91, 78, 102, 84, 88, 45, 51, 34, 47, 38, 39, 97, 91, 38, 32])
33
- credit = np.array([970, 880, 1020, 910, 805, 800, 804, 708, 470, 309, 450, 304, 380, 501, 370, 301, 1080, 902])
34
  labels = np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1])
35
 
36
  colors = ['green' if label == 1 else 'red' for label in labels]
@@ -67,7 +67,7 @@ def render():
67
 
68
  # Highlight specific point
69
  if highlight_point is not None:
70
- ax.scatter(*highlight_point, c='yellow', edgecolors='black', s=200, zorder=5)
71
 
72
  ax.spines['right'].set_visible(False)
73
  ax.spines['top'].set_visible(False)
@@ -90,6 +90,7 @@ def render():
90
  col1, col2, col3, col4, col5 = st.columns([0.5, 1, 1, 1, 0.5])
91
  with col2:
92
  st.pyplot(plot_scatter(income, credit, colors, boundary_type="vertical", highlight_point=highlight_point))
 
93
  if graph_selected=="vertical":
94
  button_click_v = st.button("Choose Model 1", type="primary")
95
  else:
@@ -100,6 +101,7 @@ def render():
100
  st.rerun()
101
  with col3:
102
  st.pyplot(plot_scatter(income, credit, colors, boundary_type="slant", highlight_point=highlight_point))
 
103
  if graph_selected=="slant":
104
  button_click_s = st.button("Choose Model 2", type="primary")
105
  else:
@@ -110,6 +112,7 @@ def render():
110
  st.rerun()
111
  with col4:
112
  st.pyplot(plot_scatter(income, credit, colors, boundary_type="horizontal", highlight_point=highlight_point))
 
113
  if graph_selected=="horizontal":
114
  button_click_h = st.button("Choose Model 3", type="primary")
115
  else:
@@ -119,6 +122,15 @@ def render():
119
  st.session_state.graph_selected = "horizontal"
120
  st.rerun()
121
 
 
 
 
 
 
 
 
 
 
122
  st.markdown("---")
123
  col1, col2, col3, col4 = st.columns([2, 1, 1, 1])
124
  with col3:
 
29
 
30
  st.markdown("---")
31
 
32
+ income = np.array([80, 85, 97, 91, 78, 102, 84, 88, 81, 40, 45, 51, 34, 47, 38, 39, 97, 91, 38, 32])
33
+ credit = np.array([970, 880, 1020, 910, 805, 800, 804, 708, 810, 370, 470, 309, 450, 304, 380, 501, 370, 301, 1080, 902])
34
  labels = np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1])
35
 
36
  colors = ['green' if label == 1 else 'red' for label in labels]
 
67
 
68
  # Highlight specific point
69
  if highlight_point is not None:
70
+ ax.scatter(*highlight_point, c='green', edgecolors='black', s=200, zorder=5, linewidths=3)
71
 
72
  ax.spines['right'].set_visible(False)
73
  ax.spines['top'].set_visible(False)
 
90
  col1, col2, col3, col4, col5 = st.columns([0.5, 1, 1, 1, 0.5])
91
  with col2:
92
  st.pyplot(plot_scatter(income, credit, colors, boundary_type="vertical", highlight_point=highlight_point))
93
+ st.markdown("Accuracy: 90%")
94
  if graph_selected=="vertical":
95
  button_click_v = st.button("Choose Model 1", type="primary")
96
  else:
 
101
  st.rerun()
102
  with col3:
103
  st.pyplot(plot_scatter(income, credit, colors, boundary_type="slant", highlight_point=highlight_point))
104
+ st.markdown("Accuracy: 90%")
105
  if graph_selected=="slant":
106
  button_click_s = st.button("Choose Model 2", type="primary")
107
  else:
 
112
  st.rerun()
113
  with col4:
114
  st.pyplot(plot_scatter(income, credit, colors, boundary_type="horizontal", highlight_point=highlight_point))
115
+ st.markdown("Accuracy: 90%")
116
  if graph_selected=="horizontal":
117
  button_click_h = st.button("Choose Model 3", type="primary")
118
  else:
 
122
  st.session_state.graph_selected = "horizontal"
123
  st.rerun()
124
 
125
+ if "graph_selected" in st.session_state:
126
+ multiplicity_message = "Notice the highlighted individual who should have gotten loan but your selected model rejected them.\
127
+ They are asking justification for selecting this model, when there existed another model with same accuracy\
128
+ that would have given this individual the loan!"
129
+ st.markdown(
130
+ f"<div style='text-align:center; color:#c0392b; font-size:20px; font-weight:bold; margin:14px 0;'>{multiplicity_message}</div>",
131
+ unsafe_allow_html=True,
132
+ )
133
+
134
  st.markdown("---")
135
  col1, col2, col3, col4 = st.columns([2, 1, 1, 1])
136
  with col3: