File size: 3,311 Bytes
89d10a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
86
87
88
89

import streamlit as st
from utils import AgeAnalysis


age_analytics = AgeAnalysis()



st.title("Transactions Amount")

st.markdown("####  Transactions Amount and Age Group")
amount_category, amount_query_result = st.columns([0.3,0.7])
with amount_category:
    amount_query = st.radio(
        label="Choose the amount block", 
        options=['Greater than 1000', 'Less than 1000', 'Less than 500', 
                 'Less than 300', 'Less than 100']
    )

    fraud_only = st.checkbox("Fraudulent only", value=True)
    age_category = st.selectbox(
        "Age Group", options=['All','40-60', '25-40', '60-80', '80+', '<25'], index=5)
    sample_size_for_amount_query = st.number_input(
        label="Sample size", min_value=1000, max_value=5000, step=1000, value=2000)
with amount_query_result:
    with st.spinner('⏳Loading the figure...'):
        st.pyplot(
            fig=age_analytics.KDE_plot_age_group_and_transaction_amount(
                amount_query, sample_size=sample_size_for_amount_query, 
                fraud_only=fraud_only, age_group=age_category)
            )


st.markdown("""
####  `Transactions Amount` across different `Age Groups`
* Minimum Transactions Amount in the dataset : `$1.0`
* Maximum Transactions Amount in the dataset : `$28948.9`
""")
transaction_sample_size, transaction_amount_lower, transaction_amount_upper = st.columns(3)
with transaction_sample_size:
    sample_size_for_transaction_amount_comparison = st.number_input(
        label="Sample size", min_value=1000, max_value=5000, step=1000, value=2000, key='sample_size_for_transaction_amount_comparison')
with transaction_amount_lower:
    transaction_amount_lowerbound = st.number_input(
        label="Transaction lowebound", min_value=1, max_value=28949, value=100, step=100,key='transaction_amount_lowerbound')
with transaction_amount_upper:
    transaction_amount_upperbound = st.number_input(
        label="Transaction lowebound", min_value=1, max_value=28949, value=500, step=100,key='transaction_amount_upperbound')

if transaction_amount_lowerbound > transaction_amount_upperbound:
    st.warning(
        f'''
        Message : `lowerbound` must be less than `upperbound` 
        ''', icon="⚠️")
    transaction_amount_lowerbound = 1
    transaction_amount_upperbound = 100

with st.spinner('⏳Loading the figure...'):
    st.pyplot(
        fig=age_analytics.compare_transactions_across_age_group(
            sample_size=sample_size_for_transaction_amount_comparison, 
            lowerbound= transaction_amount_lowerbound, upperbound=transaction_amount_upperbound
        )
    )



st.markdown("####  Transactions Amount")

transaction_amount = st.radio(
    label="Choose the amount block", 
    options=['Less than 1000', 'Less than 500', 
                'Less than 300', 'Less than 100'],
    key='transaction_amount_study', index=2,
    horizontal=True
)
age_category_for_transaction_query = st.selectbox(
    "Age Group", options=['All','40-60', '25-40', '60-80', '80+', '<25'], index=1,
    key='age_category_for_transaction_query'
)
with st.spinner("⏳Loading the figure..."):
    st.pyplot(
        fig=age_analytics.transaction_amount_study(
            query=transaction_amount, age_group=age_category_for_transaction_query),
        use_container_width=True
    )