prakharg24 commited on
Commit
c62c72d
·
verified ·
1 Parent(s): 0c434b3

Update my_pages/rashomon_effect.py

Browse files
Files changed (1) hide show
  1. my_pages/rashomon_effect.py +22 -7
my_pages/rashomon_effect.py CHANGED
@@ -4,7 +4,17 @@ import numpy as np
4
  from utils import go_to
5
 
6
  def render():
7
- st.title("Rashomon Effect")
 
 
 
 
 
 
 
 
 
 
8
 
9
  # Generate synthetic data
10
  np.random.seed(42)
@@ -21,7 +31,10 @@ def render():
21
  ax.scatter(x, y, c=colors, alpha=0.6)
22
  ax.set_xlabel("Annual Income")
23
  ax.set_ylabel("Credit Score")
24
- ax.set_title(title)
 
 
 
25
 
26
  # Decision boundary
27
  if decision_boundary is not None:
@@ -46,23 +59,25 @@ def render():
46
  return fig
47
 
48
  # Top scatter plot (centered to match smaller width)
49
- col1, col2, col3, col4, col5 = st.columns([1, 1, 1, 1, 1])
50
- with col3:
51
  st.pyplot(plot_scatter(income, credit, colors, title="Original Data"))
52
 
 
53
  with col2:
54
  st.pyplot(plot_scatter(income, credit, colors, title="Vertical Boundary",
55
  decision_boundary=55, boundary_type="vertical"))
56
  left_selected = st.button("Choose Vertical Boundary")
57
- with col4:
58
  st.pyplot(plot_scatter(income, credit, colors, title="Horizontal Boundary",
59
  decision_boundary=55, boundary_type="horizontal"))
60
  right_selected = st.button("Choose Horizontal Boundary")
61
 
 
62
  # Show new individual based on selection
63
  if left_selected:
64
  new_point = (40, 80) # High credit score, low income
65
- with col3:
66
  st.pyplot(plot_scatter(income, credit, colors,
67
  title="Vertical Boundary + New Individual",
68
  decision_boundary=55, boundary_type="vertical",
@@ -70,7 +85,7 @@ def render():
70
  st.warning("This individual was rejected by your chosen model. Why not choose a model that helps them?")
71
  elif right_selected:
72
  new_point = (80, 40) # Low credit score, high income
73
- with col3:
74
  st.pyplot(plot_scatter(income, credit, colors,
75
  title="Horizontal Boundary + New Individual",
76
  decision_boundary=55, boundary_type="horizontal",
 
4
  from utils import go_to
5
 
6
  def render():
7
+ st.markdown(
8
+ """
9
+ <div style='text-align: center; font-size:18px; color:gray;'>
10
+ Consider data about individuals who paid back their loans (green) and those who defaulted (red). <br>
11
+ Which model out of the two will you choose as your final model to give loan applications? <br><br>
12
+ </div>
13
+ """,
14
+ unsafe_allow_html=True
15
+ )
16
+
17
+ st.markdown("---")
18
 
19
  # Generate synthetic data
20
  np.random.seed(42)
 
31
  ax.scatter(x, y, c=colors, alpha=0.6)
32
  ax.set_xlabel("Annual Income")
33
  ax.set_ylabel("Credit Score")
34
+ # ax.set_title(title)
35
+
36
+ fig.patch.set_alpha(0)
37
+ ax.patch.set_alpha(0)
38
 
39
  # Decision boundary
40
  if decision_boundary is not None:
 
59
  return fig
60
 
61
  # Top scatter plot (centered to match smaller width)
62
+ col1, col2, col3 = st.columns([1.5, 1, 1.5])
63
+ with col2:
64
  st.pyplot(plot_scatter(income, credit, colors, title="Original Data"))
65
 
66
+ col1, col2, col3, col4 = st.columns([1, 1, 1, 1])
67
  with col2:
68
  st.pyplot(plot_scatter(income, credit, colors, title="Vertical Boundary",
69
  decision_boundary=55, boundary_type="vertical"))
70
  left_selected = st.button("Choose Vertical Boundary")
71
+ with col3:
72
  st.pyplot(plot_scatter(income, credit, colors, title="Horizontal Boundary",
73
  decision_boundary=55, boundary_type="horizontal"))
74
  right_selected = st.button("Choose Horizontal Boundary")
75
 
76
+ col1, col2, col3 = st.columns([1.5, 1, 1.5])
77
  # Show new individual based on selection
78
  if left_selected:
79
  new_point = (40, 80) # High credit score, low income
80
+ with col2:
81
  st.pyplot(plot_scatter(income, credit, colors,
82
  title="Vertical Boundary + New Individual",
83
  decision_boundary=55, boundary_type="vertical",
 
85
  st.warning("This individual was rejected by your chosen model. Why not choose a model that helps them?")
86
  elif right_selected:
87
  new_point = (80, 40) # Low credit score, high income
88
+ with col2:
89
  st.pyplot(plot_scatter(income, credit, colors,
90
  title="Horizontal Boundary + New Individual",
91
  decision_boundary=55, boundary_type="horizontal",