Spaces:
Runtime error
Runtime error
Update prediction.py
Browse files- prediction.py +22 -21
prediction.py
CHANGED
@@ -60,27 +60,28 @@ def run():
|
|
60 |
data_inf = pd.DataFrame([data_inf])
|
61 |
st.dataframe(data_inf)
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
84 |
|
85 |
if __name__== '__main__':
|
86 |
run()
|
|
|
60 |
data_inf = pd.DataFrame([data_inf])
|
61 |
st.dataframe(data_inf)
|
62 |
|
63 |
+
if submitted:
|
64 |
+
# Split between Numerical Columns and Categorical Columns
|
65 |
+
|
66 |
+
data_inf_num = data_inf[list_num_cols]
|
67 |
+
data_inf_cat = data_inf[list_cat_cols]
|
68 |
+
|
69 |
+
# Feature Scaling and Feature Encoding
|
70 |
+
|
71 |
+
data_inf_num_scaled = model_scaler.transform(data_inf_num)
|
72 |
+
data_inf_final = np.concatenate([data_inf_num_scaled], axis=1)
|
73 |
+
|
74 |
+
# Prediksi menggunakan random forest
|
75 |
+
|
76 |
+
y_pred_inf = loaded_model.predict(data_inf_final)
|
77 |
+
|
78 |
+
# Mengubah hasil prediksi menjadi label yang sesuai
|
79 |
+
if y_pred_inf == 0:
|
80 |
+
hasil_prediksi = "Ada Harapan"
|
81 |
+
else:
|
82 |
+
hasil_prediksi = "Death"
|
83 |
+
|
84 |
+
st.write('# Kemungkinan : ', hasil_prediksi)
|
85 |
|
86 |
if __name__== '__main__':
|
87 |
run()
|