import streamlit as st import pandas as pd import seaborn as sns import matplotlib.pyplot as plt from PIL import Image st.set_page_config( page_title='HEART FAILURE - EDA', layout='wide', initial_sidebar_state='expanded' ) def run(): # Membuat Title st.title('Death Event Prediction') # Membuat Sub Header st.subheader('EDA for Heart Failure Death Event') # Menambahkan Gambar image = Image.open('heart.jpeg') st.image(image, caption='Heart Failure') # Menambahkan Deskripsi st.write('This page created by **Imam Zarkasie**') # Membuat Garis Lurus st.markdown('---') # Magic Syntax ''' On this page, the author will do a simple exploration. The dataset used is the Heart Failure dataset. This dataset comes from the Google Bigquery. ''' # Show DataFrame data = pd.read_csv('h8dsft_P1G3_Imam_Zarkasie.csv') st.dataframe(data) # Membuat Pie Plot Patient Death Event st.write('#### Pie Plot Patient Death Event') fig, ax = plt.subplots(figsize=(5, 6)) data['DEATH_EVENT'].value_counts().plot(kind='pie', autopct='%1.1f%%', startangle=90, shadow=True) plt.title('Pie Plot Patient Death Event') plt.axis('equal') # Sets the pie chart to look like a circle. st.pyplot(fig) # Create Histogram of serum_creatinine st.write('#### Histogram of serum_creatinine') fig, ax = plt.subplots(figsize=(8, 5)) sns.histplot(data['serum_creatinine'], kde=True, bins=30) plt.title('Histogram of serum_creatinine') st.pyplot(fig) # Create Scatter Plot of Age VS Platelets st.write('#### Scatter Plot of Age VS Platelets') fig, ax = plt.subplots(figsize=(8, 5)) sns.scatterplot(x='age', y='platelets', data=data) plt.title('Scatter Plot of Age VS Platelets') st.pyplot(fig) # Pie Plot Smoking Patient st.write('#### Pie Plot Smoking Patient') fig, ax = plt.subplots(figsize=(5, 6)) data['smoking'].value_counts().plot(kind='pie', autopct='%1.1f%%', startangle=90, shadow=True) plt.title('Pie Plot Smoking Patient') plt.axis('equal') # Sets the pie chart to look like a circle. st.pyplot(fig) if __name__ == '__main__': run()