import streamlit as st import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import plotly.express as px from PIL import Image def run(): #membuat judul st.title('Credit Card prediction') #membuat sub header st.subheader('Tugas GC5') #menambahkan deskripsi st.write('Page ini dibuat oleh Andryan wijaya') #tambahkan gambar image = Image.open('credit.png') st.image(image, caption = 'credit card') #show dataframe st.write('# Data') data = pd.read_csv('P1G5_Set_1_Andryan_wijaya.csv') st.dataframe(data) st.write('# Boxplot Limit balance') fig = plt.figure(figsize=(15,5)) sns.boxplot(x='limit_balance', data = data) st.pyplot(fig) st.write('Maximum balance:',data['limit_balance'].max()) st.write('Minimum balance:',data['limit_balance'].min()) st.write('Average balance:',data['limit_balance'].mean()) st.write('# Bar plot sex') fig = plt.figure(figsize=(15,5)) sns.barplot(y=data['sex'].value_counts(),x='sex', data = data,) st.pyplot(fig) st.write('Male: 1') st.write('Female: 2') st.write('# Bar plot Marital status') fig = plt.figure(figsize=(15,5)) sns.barplot(y=data['marital_status'].value_counts(),x='marital_status', data = data,) st.pyplot(fig) st.write('Married: 1') st.write('Single: 2') st.write('Others: 3') st.write('# Boxplot Age') fig = plt.figure(figsize=(15,5)) sns.boxplot(x='age', data = data) st.pyplot(fig) st.write('Maximum age:',data['age'].max()) st.write('Minimum age:',data['age'].min()) st.write('Average age:',data['age'].mean()) st.write('# Countplot Pay') fig = plt.figure(figsize=(15,5)) sns.countplot(data=data[['pay_0', 'pay_2', 'pay_3', 'pay_4', 'pay_5', 'pay_6']].melt(), x='value', hue='variable') plt.xlabel('Nilai Variabel Biner') plt.ylabel('Jumlah Data') plt.title('Perbandingan Kategori Variabel pay') st.pyplot(fig) st.write('# Countplot bill') fig = plt.figure(figsize=(15,5)) sns.barplot(data=data[['bill_amt_1', 'bill_amt_2', 'bill_amt_3', 'bill_amt_4', 'bill_amt_5', 'bill_amt_6']].melt(), y='value', hue='variable') plt.ylabel('Jumlah Data') plt.title('Perbandingan Kategori Variabel bill') st.pyplot(fig) st.write('# Countplot bill') fig = plt.figure(figsize=(15,5)) sns.barplot(data=data[['pay_amt_1', 'pay_amt_2', 'pay_amt_3', 'pay_amt_4', 'pay_amt_5', 'pay_amt_6']].melt(), y='value', hue='variable') plt.ylabel('Jumlah Data') plt.title('Perbandingan Kategori Variabel pay amt') st.pyplot(fig) st.write('# Bar plot default payment') fig = plt.figure(figsize=(15,5)) sns.barplot(y=data['default_payment_next_month'].value_counts(),x='default_payment_next_month', data = data,) st.pyplot(fig) st.write('Yes: 1') st.write('No: 2') if __name__ == '__main__': run()