Spaces:
Runtime error
Runtime error
File size: 4,189 Bytes
eaf6202 dba73d1 eaf6202 dba73d1 eaf6202 dba73d1 eaf6202 |
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
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='EDA',
layout='wide',
initial_sidebar_state='expanded'
)
def run():
# title
st.title('Predicting Patient Survival')
# sub header
st.subheader('Understanding Mortality Risk Factors and Predictive Modeling')
# add pic
image = Image.open('heart.png')
st.image(image, caption='Health Parameter')
# add text
'''
Page ini dibuat untuk memprediksi **kematian pasien** dengan menggunakan
dataset yang tersedia. Dengan melakukan explorasi, akan ditinjau beberapa
insight yang dapat menjadi faktor-faktor / variabel yang membuat seorang
pasien dapat diprediksi meninggal atau tidak.
'''
markdown_text = '''
## Variable Descriptions
| Variable | Description |
|-------------------------|-----------------------------------------------------------------------------------------------|
| age | Age of the patient in years. |
| anaemia | Whether the patient has anemia or not. (1=True, 0=False) |
| creatinine_phosphokinase| Level of the enzyme creatinine phosphokinase in the patient's blood in units (mcg/L). |
| diabetes | Whether the patient has diabetes or not. (1=True, 0=False) |
| ejection_fraction | Percentage of blood volume ejected from the heart during each contraction. |
| high_blood_pressure | Whether the patient has high blood pressure or not. (1=True, 0=False) |
| platelets | Level of platelets in the patient's blood in units (kiloplatelets/mL). |
| serum_creatinine | Level of creatinine in the patient's blood in units (mg/dL). |
| serum_sodium | Level of sodium in the patient's blood in units (mEq/L). |
| sex | Gender of the patient. (0=Male, 1=Female) |
| smoking | Whether the patient smokes or not. (1=True, 0=False) |
| time | Follow-up period in days. |
| DEATH_EVENT | Indicator of whether the patient experienced a death event or not. (1=True, 0=False) |
'''
st.markdown(markdown_text)
st.markdown('---')
st.subheader('Explorasi Data')
st.markdown('---')
st.write('### Tabel Data Pasien')
# show dataframe
data = pd.read_csv('h8dsft_P1G3_Andikaa_Atmanegara_Putra.csv')
st.dataframe(data)
st.markdown('---')
# visual barplot
st.write('### Histogram Berdasarkan User Input ')
choice = st.selectbox('Pilih Columns: ', ('age', 'anaemia',
'sex', 'DEATH_EVENT',
'creatinine_phosphokinase',
'platelets'))
fig = plt.figure(figsize=(15,5))
sns.histplot(data[choice], bins=30, kde=True)
st.pyplot(fig)
# visual 2
## Categorical Data Plot
st.write('### Categorical Data Ratio')
pilihan_kategori = st.selectbox('Pick Categorical Column : ', ('anaemia', 'diabetes', 'high_blood_pressure',
'sex', 'smoking'))
fig= plt.figure(figsize=(8, 6))
sns.countplot(data=data, x=pilihan_kategori, hue='DEATH_EVENT', palette=['limegreen', 'firebrick'])
plt.xlabel(pilihan_kategori.capitalize())
plt.ylabel('Count')
plt.title(pilihan_kategori.capitalize()+' Ratio')
plt.legend(title='DEATH_EVENT')
st.pyplot(fig)
if __name__ == '__main__':
run() |