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 # Melebarkan visualisasi untuk memaksmalkan browser st.set_page_config( page_title='Heart Failure', layout='wide', initial_sidebar_state='expanded' ) def run(): # Membuat title st.title('Patients with Heart Failure-Death Prediction') # Menambahkan Gambar image = Image.open('heart.jpg') st.image(image, caption='Heart Failure') # Menambahkan Deskripsi st.write('## Definition') st.write('Heart failure is progressive condition in which the heart muscle is unable to pump enough blood to meet the body needs for blood and oxygen.' 'Basically, the heart cant keep up with its workload.' 'Heart failure can caused by diabetes, smoking, and high of blood pressure.' 'Heart failure can cause death in chronic and acute conditions.') st.write('## Heart and kidney') st.write('The interaction between the heart and kidney can often become deranged in heart failure.' 'Not only do heart failure and chronic kidney disease (CKD) often co-exist and share common risk factors in their development, both heart and kidney disease can worsen each others prognosis.' 'The preload of the heart directly depends on the sodium and water homeostasis regulated by the kidney.' 'The kidney depends on adequate contraction and relaxation of the heart to have a sufficient trans-renal pressure gradient to maintain renal blood flow (RBF).' 'So, heart failure have a correlation with sodium level in blood and creatinin (CPK enzyme).') # Membuat Garis Lurus st.markdown('---') # Membuat Sub Headrer st.subheader('EDA for Analyze Patients') # Magic Syntax ''' On this page, the author will do a simple exploration. The dataset used is the Heart Failure dataset. This dataset comes from GCP in the Hacktiv8 project. ''' # Show DataFrame df1 = pd.read_csv('h8dsft_P1G3_fadya_ulya.csv') st.dataframe(df1) # Membuat Barplot st.write('#### Plot Death Event') fig = plt.figure(figsize=(15,8)) sns.countplot(x='DEATH_EVENT', data=df1, palette="PuRd") st.pyplot(fig) # Membuat Barplot Diabetes, Smoking, dan Darah Tinggi st.write('#### Diabetes') plt.figure(figsize=(15,8)) sns.countplot(x='diabetes', data=df1, palette="Blues") st.pyplot(fig) st.write('#### High Blood Pressure') plt.figure(figsize=(15,8)) sns.countplot(x='high_blood_pressure', data=df1, palette="Blues") st.pyplot(fig) st.write('#### Smoking') plt.figure(figsize=(15,8)) sns.countplot(x='smoking', data=df1, palette="Blues") st.pyplot(fig) # Membuat Histogram Berdasarkan Input User st.write('#### Histogram Based On User Input') pilihan = st.selectbox('Choose Column : ', ('age', 'creatinine_phosphokinase', 'ejection_fraction', 'platelets', 'serum_sodium', 'serum_creatinine', 'time')) fig = plt.figure(figsize=(15,5)) sns.histplot(df1[pilihan], bins=30, kde=True) st.pyplot(fig) if __name__ == '__main__': run()