File size: 3,748 Bytes
93a1da5
6e2c065
c6fa63e
0733035
 
a400f33
 
 
 
 
 
ee2c687
a400f33
ee2c687
a400f33
ee2c687
a400f33
0733035
 
 
191cbb3
5f3a336
 
 
 
5d51b2c
 
5f3a336
 
191cbb3
87dd542
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e2c065
87dd542
 
0733035
 
 
87dd542
0733035
87dd542
0733035
30c29e9
 
93a1da5
0733035
87dd542
 
d3b8b95
87dd542
d3b8b95
87dd542
c04f062
87dd542
d3b8b95
6e2c065
0733035
c6fa63e
f6dd689
f1a9c5d
ee2c687
c04f062
 
 
ee2c687
c04f062
6bbeeab
d1736b4
c04f062
d1736b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import pandas as pd
import streamlit as st
from utils import add_navigation, add_instruction_text, add_red_text

ALL_FEATURES = [
    ("Liquid Assets", ["Liquid Assets"], 
     "Great choice! With access to bank accounts, a measure of all liquid assets can really help make a decision about loan approval."), 
    ("Illiquid Assets", ["Property appraisals", "Insurance valuations"], 
     "Oops, it is not possible to precisely calculate the value of illiquid assets! We will use some approximate alternatives instead."),
    ("Debt Obligations", ["Credit Card Debts", "Bank Loans", "Self-reported Debts"], 
     "Oops, it is not possible to precisely measure all debt obligations! We will use credit card debts, bank loans, and other self-reported debts as approximate alternatives instead."),
    ("Income Stability", ["Past Income Stability"],
     "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 can instead approximate with past income stability."),
    ("Health Trajectory", ["Current Health Indicators"], 
     "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 can instead approximate with current health indicators."),
    ("Financial Discipline", ["Credit Score"], 
     "Oops, financial discipline is not a directly measurable quality. We will use credit score as an approximation instead.")
]

def render():
    add_navigation("txt_information_loss", "txt_rashomon_effect")

    add_instruction_text(
        """
        Consider the automation of loan approval using AI models. <br>
        Select the features below that you would like to collect to train your AI model. <br>
        Notice that, in trying to capture data from the real world, you loose information.
        """
    )
    
    #### Setup Button Colors and Theme
    sec_bg = st.get_option("theme.secondaryBackgroundColor")
    text = st.get_option("theme.textColor")
    
    css = f"""
    <style>
    button[kind="tertiary"] {{
        background-color: {sec_bg} !important;
        color: {text} !important;
        border: 1px solid {sec_bg} !important;
        opacity: 0.2 !important;       /* faded look */
        cursor: not-allowed !important;  /* shows it's inactive */
        pointer-events: none !important; /* disable clicking */
    }}
    </style>
    """
    st.markdown(css, unsafe_allow_html=True)

    
    #### Add the icon and buttons at the top
    if "selected_features" not in st.session_state:
        st.session_state.selected_features = []

    cols_list = st.columns([1, 1, 1, 1])

    with cols_list[0]:
        st.image(
            "loan.png",
            width=100,
        )

    for ite, feature in enumerate(ALL_FEATURES.copy()):
        with cols_list[ite%3 + 1]:
            if feature in st.session_state.selected_features:
                _ = st.button(feature[0], type="tertiary")
            else:
                if st.button(feature[0]):
                    st.session_state.selected_features.append(feature)
                    st.session_state.show_message = feature[2]
                    st.rerun()

    if "show_message" in st.session_state:
        add_red_text(st.session_state.show_message)
        del st.session_state.show_message

    #### Selected features shown at the bottom
    display_features_list = []
    for ele in st.session_state.selected_features:
        display_features_list.extend(ele[1])
    
    st.markdown("---")
    st.markdown("**Set of Selected Features:**")
    cols_list = st.columns(3)
    for i, item in enumerate(display_features_list):
        cols_list[i%3].markdown(f"- {item}")