|
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 = 'Heart Failure - EDA', |
|
layout = 'wide', |
|
initial_sidebar_state = 'expanded' |
|
) |
|
|
|
def run() : |
|
|
|
|
|
st.title('Heart Rate Survivor Prediction') |
|
|
|
|
|
st.subheader('EDA untuk Analisa Dataset Heart Failure') |
|
|
|
|
|
image = Image.open('heart.jpg') |
|
st.image(image, caption='Love your Heart') |
|
|
|
|
|
st.write('Page ini dibuat oleh **Satriya Fauzan Adhim**') |
|
|
|
|
|
st.markdown('---') |
|
|
|
|
|
''' |
|
Pada page ini, penulis akan melakukan eksplorasi sederhana dari dataset Heart Failure. |
|
Dataset yang digunakan adalah dataset yang berisikan tentang data terkait dengan heart failure. |
|
Dataset diambil dari Google Bigquery. |
|
|
|
''' |
|
|
|
|
|
data = pd.read_csv('https://raw.githubusercontent.com/kodokgodog/Latihan_hactiv8/main/h8dsft_P1G3_Satriya_Fauzan_Adhim.csv') |
|
st.dataframe(data) |
|
|
|
|
|
st.write('#### Plot DEATH_EVENT') |
|
fig = plt.figure(figsize=(15, 5)) |
|
sns.countplot(x='DEATH_EVENT', data=data) |
|
st.pyplot(fig) |
|
|
|
|
|
st.write('#### Histogram of ejection_fraction') |
|
fig = plt.figure(figsize=(15, 5)) |
|
sns.histplot(data['ejection_fraction'], bins=30, kde=True) |
|
st.pyplot(fig) |
|
|
|
|
|
st.write('#### Histogram berdasarkan input user') |
|
pilihan = st.selectbox('Pilih column : ', ('age', 'ejection_fraction', 'serum_creatinine', 'serum_sodium')) |
|
fig = plt.figure(figsize=(15, 5)) |
|
sns.histplot(data[pilihan], bins=30, kde=True) |
|
st.pyplot(fig) |
|
|
|
|
|
st.write('#### Plotly Plot - anaemia dengan DEATH_EVENT') |
|
fig = px.scatter(data, x='anaemia', y='DEATH_EVENT', hover_data=['age']) |
|
st.plotly_chart(fig) |
|
|
|
if __name__== '__main__': |
|
run() |