AdeWT's picture
Upload 6 files
b12a49b
raw
history blame
No virus
2.39 kB
import streamlit as st
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px
def run():
#Membuat title
st.title('Credit Default Predictor - Exploratory Data Analysis')
#Membuat subheader
st.subheader('Exploratory Data Analysis of the model Credit Default Predictor')
#Membuat garis
st.markdown('----')
#Masukkan pandas dataframe
#Show dataframe
df = pd.read_csv('https://raw.githubusercontent.com/AdeWT/AdeWT-Hacktiv8-things/main/BigQuery_credit_card_default_27_12_2023.csv')
st.dataframe(df)
#Membuat bar plot
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)
#Membuat histogram
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)
#tambah penjelas
#membuat histogram berdasarkan inputan user
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')
#Membuat Plotly plot
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()