hilalrd commited on
Commit
c4c99da
1 Parent(s): 5d48ad0

Update prediction.py

Browse files
Files changed (1) hide show
  1. 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
- # Split between Numerical Columns and Categorical Columns
64
-
65
- data_inf_num = data_inf[list_num_cols]
66
- data_inf_cat = data_inf[list_cat_cols]
67
-
68
- # Feature Scaling and Feature Encoding
69
-
70
- data_inf_num_scaled = model_scaler.transform(data_inf_num)
71
- data_inf_final = np.concatenate([data_inf_num_scaled], axis=1)
72
-
73
- # Prediksi menggunakan random forest
74
-
75
- y_pred_inf = loaded_model.predict(data_inf_final)
76
-
77
- # Mengubah hasil prediksi menjadi label yang sesuai
78
- if y_pred_inf == 0:
79
- hasil_prediksi = "Ada Harapan"
80
- else:
81
- hasil_prediksi = "Death"
82
-
83
- st.write('# Kemungkinan : ', hasil_prediksi)
 
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()