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 st.set_page_config( page_title = 'Death Prediction' ) def run(): # Membuat Title st.title('Death Prediction Simulator') #Sub header st.subheader('EDA untuk analisa Dataset Death Prediction') # Insert Gambar #image = Image.open('') #st.image(image, caption ='Death Prediction') # Menambahkan Deskripsi st.write('Page ini dibuat oleh Ferdiansyah Ersatiyo') st.markdown('---') #show dataframe data = pd.read_csv('https://raw.githubusercontent.com/FerdiErs/SQL/main/h8dsft_P1G3_Ferdiansyah_Ersatiyo.csv') st.dataframe(data) #membuat barplot jenis kelamin st.write('### Plot Sex') fig = plt.figure(figsize=(10,5)) ax = sns.countplot(x='sex', data=data, palette=['b', 'r']) ax.bar_label(ax.containers[0]) st.pyplot(fig) #membuat histogram umur st.write('### Histogram Umur') fig = plt.figure(figsize=(10,5)) sns.histplot(data['age'],bins=20,kde=True) st.pyplot(fig) #membuat pie chart st.write('### Pie Chart Smoking') a= data.smoking.value_counts() def autopct_format(values): def my_format(pct): total = sum(values) val = int(round(pct*total/100.0)) return '{:.1f}%\n({v:d})'.format(pct, v=val) return my_format fig = plt.figure(figsize=(5,5)) a.plot.pie(subplots=True, autopct=autopct_format(a)) st.pyplot(fig) # Membuat Histogram berdasarkan input user st.write('### Histogram berdasarkan input user') pilihan = st.selectbox('pilih column : ',['sex','smoking','diabetes', 'anaemia','high_blood_pressure']) fig = plt.figure(figsize=(10,5)) ax = sns.countplot(x=data[pilihan]) ax.bar_label(ax.containers[0]) st.pyplot(fig) if __name__== '__main__': run()