Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import eda
|
3 |
import models
|
@@ -75,4 +76,4 @@ Bagaimana model prediksi ini akan diuji, divalidasi, dan dioptimalkan untuk mema
|
|
75 |
elif page == 'Exploration Data Analysis':
|
76 |
eda.run()
|
77 |
else:
|
78 |
-
models
|
|
|
1 |
+
import numpy as np
|
2 |
import streamlit as st
|
3 |
import eda
|
4 |
import models
|
|
|
76 |
elif page == 'Exploration Data Analysis':
|
77 |
eda.run()
|
78 |
else:
|
79 |
+
models.run()
|
eda.py
CHANGED
@@ -8,11 +8,14 @@ from PIL import Image
|
|
8 |
#membuat function untuk nantinya dipanggil di app.py
|
9 |
def run():
|
10 |
st.title('Welcome to Explaration Data Analysis')
|
|
|
|
|
11 |
#Memanggil data csv
|
12 |
df= pd.read_csv(r'heart_failure.csv')
|
13 |
|
14 |
#menampilakn 5 data teratas
|
15 |
-
st.table(df.head(
|
|
|
16 |
|
17 |
|
18 |
#menampilakn phik matrix
|
|
|
8 |
#membuat function untuk nantinya dipanggil di app.py
|
9 |
def run():
|
10 |
st.title('Welcome to Explaration Data Analysis')
|
11 |
+
st.subheader ('Eda Mardi ML 2')
|
12 |
+
|
13 |
#Memanggil data csv
|
14 |
df= pd.read_csv(r'heart_failure.csv')
|
15 |
|
16 |
#menampilakn 5 data teratas
|
17 |
+
st.table(df.head())
|
18 |
+
st.table(df.tail())
|
19 |
|
20 |
|
21 |
#menampilakn phik matrix
|
models.py
CHANGED
@@ -1,46 +1,34 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import pickle
|
|
|
4 |
|
5 |
def run():
|
6 |
-
# Load All Files
|
7 |
-
|
8 |
-
with open('best_linear_svm_model.pkl', 'rb') as file:
|
9 |
full_process = pickle.load(file)
|
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 |
-
st.metric(label="Prediksinya adalah : ", value = y_pred_inf[0])
|
38 |
-
|
39 |
-
# If your data is a classification, you can follow the example below
|
40 |
-
# if y_pred_inf[0] == 0:
|
41 |
-
# st.write('Pasien tidak terkena jantung')
|
42 |
-
# st.markdown("[Cara Cegah Serangan Jantung](https://www.siloamhospitals.com/informasi-siloam/artikel/cara-cegah-serangan-jantung-di-usia-muda)")
|
43 |
-
|
44 |
-
# else:
|
45 |
-
# st.write('Pasien kemungkinan terkena jantung')
|
46 |
-
# st.markdown("[Cara Hidup Sehat Sehabis Terkena Serangan Jantung](https://lifestyle.kompas.com/read/2021/11/09/101744620/7-pola-hidup-sehat-setelah-mengalami-serangan-jantung?page=all)")
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import pickle
|
4 |
+
import numpy as np
|
5 |
|
6 |
def run():
|
7 |
+
# Load All Files
|
8 |
+
with open('best_linear_svm_model.pkl', 'rb') as file:
|
|
|
9 |
full_process = pickle.load(file)
|
10 |
|
11 |
+
time = np.random.choice(['0.0', '1'], 1000)
|
12 |
+
serum_creatinine = np.random.choice(['0.0', '1'], 1000)
|
13 |
+
ejection_fraction = np.random.choice(['0.0', '1'], 1000)
|
14 |
+
|
15 |
+
time_input = st.number_input(label='Silakan Masukan Waktu', min_value=0.1, max_value=0.99)
|
16 |
+
serum_creatinine_input = st.number_input(label='Silakan Masukan serum_creatinine here', min_value=0.1, max_value=0.99)
|
17 |
+
ejection_fraction_input = st.number_input(label='Silakan Masukan ejection_fraction here', min_value=0.1, max_value=0.99)
|
18 |
+
|
19 |
+
st.write('Prediksi atas data yang Anda sampaikan adalah: ')
|
20 |
+
|
21 |
+
data_inf = pd.DataFrame({
|
22 |
+
'time': time_input,
|
23 |
+
'serum_creatinine': serum_creatinine_input,
|
24 |
+
'ejection_fraction': ejection_fraction_input,
|
25 |
+
}, index=[0])
|
26 |
+
|
27 |
+
st.table(data_inf)
|
28 |
+
|
29 |
+
if st.button(label='predict'):
|
30 |
+
# Melakukan prediksi data dummy
|
31 |
+
y_pred_inf = full_process.predict(data_inf)
|
32 |
+
st.metric(label="Prediksinya adalah:", value=y_pred_inf[0])
|
33 |
+
|
34 |
+
run() # Call the run function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|