File size: 2,390 Bytes
b12a49b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()