|
import streamlit as st |
|
import pandas as pd |
|
import seaborn as sns |
|
import matplotlib.pyplot as plt |
|
import plotly.express as px |
|
|
|
|
|
def run(): |
|
|
|
st.title('Credit Default Predictor - Exploratory Data Analysis') |
|
|
|
|
|
st.subheader('Exploratory Data Analysis of the model Credit Default Predictor') |
|
|
|
|
|
st.markdown('----') |
|
|
|
|
|
|
|
|
|
df = pd.read_csv('https://raw.githubusercontent.com/AdeWT/AdeWT-Hacktiv8-things/main/BigQuery_credit_card_default_27_12_2023.csv') |
|
st.dataframe(df) |
|
|
|
|
|
st.write('### Spread of default and non-default in the dataset') |
|
fig = plt.figure(figsize=(15,5)) |
|
sns.countplot(x='default_payment_next_month', data = df) |
|
st.pyplot(fig) |
|
|
|
|
|
st.write('### Distribution plot of limit balance') |
|
fig = plt.figure(figsize=(15,5)) |
|
sns.histplot(df['limit_balance'], bins = 30, kde = True) |
|
st.pyplot(fig) |
|
|
|
|
|
|
|
st.write('### Choose which data to see spread of') |
|
option = st.selectbox('Choose data : ', ('sex', 'education_level', 'marital_status')) |
|
fig = plt.figure(figsize= (15,5)) |
|
sns.countplot(x=option, data=df) |
|
st.pyplot(fig) |
|
st.write(f'#### sex = 1 is male, 2 is female') |
|
st.write('#### education_level =') |
|
st.write('#### 1 is graduate school') |
|
st.write('#### 2 is university') |
|
st.write('#### 3 is high school') |
|
st.write('#### 4 is others') |
|
st.write('#### 5 and 6 are unknown') |
|
st.write('#### marital_status =') |
|
st.write('#### 1 is married') |
|
st.write('#### 2 is single') |
|
st.write('#### 3 is others') |
|
|
|
|
|
|
|
st.write('### Plotly Plot - Education Level on Default Payment Next Month') |
|
fig = px.scatter(df, x = 'education_level', y = 'default_payment_next_month', hover_data = ['limit_balance', |
|
'education_level', |
|
'marital_status', |
|
'age']) |
|
st.plotly_chart(fig) |
|
st.write('#### 1 is default while 0 is no default') |
|
if __name__ == '__main__': |
|
run() |