prakharg24 commited on
Commit
d3b8b95
·
verified ·
1 Parent(s): e95a1ec

Update my_pages/information_loss.py

Browse files
Files changed (1) hide show
  1. my_pages/information_loss.py +55 -26
my_pages/information_loss.py CHANGED
@@ -3,18 +3,44 @@ import streamlit as st
3
  from utils import go_to
4
 
5
  ALL_FEATURES = [
6
- "Credit Score", "Annual Income", "Loan Amount Requested",
7
- "Number of Previous Loans", "Debt-to-Income Ratio",
8
- "Employment Stability", "Length of Credit History",
9
- "Collateral Value", "Marital Status", "Number of Dependents"
 
 
 
 
 
 
10
  ]
11
 
12
  def render():
13
- st.title("Information Loss")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  # Session state init
16
- if "available_features" not in st.session_state:
17
- st.session_state.available_features = ALL_FEATURES.copy()
18
 
19
  if "selected_features" not in st.session_state:
20
  st.session_state.selected_features = []
@@ -25,21 +51,24 @@ def render():
25
  with top_left:
26
  st.image(
27
  "https://cdn-icons-png.flaticon.com/512/1048/1048949.png",
28
- caption="Loan Applicant",
29
  width=260,
30
  )
31
 
32
  # Top right: simple clickable list of features
33
  with top_right:
34
- st.markdown("**Available Features**")
35
- for feature in st.session_state.available_features.copy():
36
- if st.button(feature, key=feature):
37
- st.session_state.selected_features.append(f"{feature} (approx)")
38
- st.session_state.available_features.remove(feature)
39
- st.session_state.show_message = (
40
- f"Sorry, '{feature}' cannot be precisely collected. Adding approximation instead."
41
- )
42
- st.rerun()
 
 
 
43
 
44
  # Centered message
45
  if "show_message" in st.session_state:
@@ -49,16 +78,16 @@ def render():
49
  )
50
  del st.session_state.show_message
51
 
52
- st.markdown("---")
53
 
54
- # Bottom half: dataset table
55
- st.markdown("### Current Dataset")
56
- if st.session_state.selected_features:
57
- cols = st.session_state.selected_features + ["Target Label"]
58
- df = pd.DataFrame(columns=cols)
59
- st.dataframe(df, use_container_width=True)
60
- else:
61
- st.info("No features added yet. Click a feature above to add it to the dataset.")
62
 
63
  st.markdown("---")
64
  col1, col2, col3, col4 = st.columns([2, 1, 1, 1])
 
3
  from utils import go_to
4
 
5
  ALL_FEATURES = [
6
+ ("Liquid Assets", "Liquid Assets", None),
7
+ ("Illiquid Assets", "Property appraisals, Insurance valuations, etc.",
8
+ "Sorry, it is not possible to get the precise value of illiquid assets. We will use some approximate alternatives instead."),
9
+ ("Current Debts", "Current Debts", None),
10
+ ("Income Stability", "Past Income Stability",
11
+ "Sorry, it is not possible to know precisely how stable someone's income will be in future. Until someone invents a time machine (we're hopeful!), we will instead use past income stability."),
12
+ ("Health Trajectory", "Current Health Indicators",
13
+ "Sorry, it is not possible to know precisely how will someone's health change in the future. Until someone invents a time machine (we're hopeful!), we will instead use current health indicators."),
14
+ ("Financial Discipline", "Credit Score",
15
+ "Sorry, financial discipline is not a directly measurable quality. We will use credit score as an approximation instead.")
16
  ]
17
 
18
  def render():
19
+ st.markdown(
20
+ """
21
+ <style>
22
+ button[kind="selected"] {
23
+ background: green!important;
24
+ }
25
+ </style>
26
+ """,
27
+ unsafe_allow_html=True,
28
+ )
29
+
30
+ st.markdown(
31
+ """
32
+ <div style='text-align: center; font-size:18px; color:gray;'>
33
+ Consider the automation of loan approval using AI models. <br>
34
+ Choose the features below that you would like to collect to train your AI model. <br><br>
35
+ </div>
36
+ ---
37
+ """,
38
+ unsafe_allow_html=True
39
+ )
40
 
41
  # Session state init
42
+ # if "available_features" not in st.session_state:
43
+ # st.session_state.available_features = ALL_FEATURES.copy()
44
 
45
  if "selected_features" not in st.session_state:
46
  st.session_state.selected_features = []
 
51
  with top_left:
52
  st.image(
53
  "https://cdn-icons-png.flaticon.com/512/1048/1048949.png",
54
+ # caption="Loan Applicant",
55
  width=260,
56
  )
57
 
58
  # Top right: simple clickable list of features
59
  with top_right:
60
+ st.markdown("**All Features**")
61
+ for feature in ALL_FEATURES.copy():
62
+ if feature in st.session_state.selected_features:
63
+ feature_name = feature[1]
64
+ _ = st.button(feature_name, key=feature_name, type="selected")
65
+ else:
66
+ feature_name = feature[0]
67
+ if st.button(feature_name, key=feature_name):
68
+ st.session_state.selected_features.append(feature)
69
+ if feature[2] is not None:
70
+ st.session_state.show_message = (feature[2])
71
+ st.rerun()
72
 
73
  # Centered message
74
  if "show_message" in st.session_state:
 
78
  )
79
  del st.session_state.show_message
80
 
81
+ # st.markdown("---")
82
 
83
+ # # Bottom half: dataset table
84
+ # st.markdown("### Current Dataset")
85
+ # if st.session_state.selected_features:
86
+ # cols = st.session_state.selected_features + ["Target Label"]
87
+ # df = pd.DataFrame(columns=cols)
88
+ # st.dataframe(df, use_container_width=True)
89
+ # else:
90
+ # st.info("No features added yet. Click a feature above to add it to the dataset.")
91
 
92
  st.markdown("---")
93
  col1, col2, col3, col4 = st.columns([2, 1, 1, 1])