transaction-analytics / pages /4_Transactions_Analytics.py
Ajay-user's picture
Upload 28 files
89d10a2
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
)