Commit ·
606cad8
1
Parent(s): 1003f35
intial commit
Browse files- app.py +34 -0
- base_model_nurse_stress_15min.pkl +3 -0
- requirements.txt +6 -0
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import joblib
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pandas as pd
|
| 5 |
+
|
| 6 |
+
# Load the PyCaret model
|
| 7 |
+
stress_model = joblib.load('base_model_nurse_stress_15min.pkl')
|
| 8 |
+
|
| 9 |
+
# Set up the main title and subtitle
|
| 10 |
+
st.title("Prediksi Tingkat Stres")
|
| 11 |
+
st.markdown("Prediksi tingkat stres untuk perawat berdasarkan input **EDA**, **HR**, dan **TEMP**. Ideal untuk aplikasi pemantauan stres!")
|
| 12 |
+
|
| 13 |
+
# Sidebar for input parameters with an expander
|
| 14 |
+
with st.sidebar.expander("🩺 Parameter Input"):
|
| 15 |
+
st.write("Masukkan parameter untuk **EDA**, **HR**, dan **TEMP** untuk memprediksi tingkat stres.")
|
| 16 |
+
eda = st.number_input("🖐️ EDA (Aktivitas Elektrodermal)", min_value=0.0, max_value=100.0, value=5.0)
|
| 17 |
+
hr = st.number_input("❤️ HR (Denyut Jantung)", min_value=0, max_value=200, value=60)
|
| 18 |
+
temp = st.number_input("🌡️ TEMP (Temperatur)", min_value=30.0, max_value=45.0, value=36.5)
|
| 19 |
+
|
| 20 |
+
# Create a "Predict" button
|
| 21 |
+
if st.button("🚑 Prediksi"):
|
| 22 |
+
# Create feature array for prediction
|
| 23 |
+
features = pd.DataFrame([[eda, hr, temp]], columns=['EDA', 'HR', 'TEMP'])
|
| 24 |
+
|
| 25 |
+
# Predict stress level
|
| 26 |
+
stress_prediction = stress_model.predict(features)[0]
|
| 27 |
+
|
| 28 |
+
# Map prediction to stress level category
|
| 29 |
+
stress_level_map = {0: "Tidak Stres", 1: "Stres Rendah", 2: "Stres Tinggi"}
|
| 30 |
+
stress_level = stress_level_map.get(stress_prediction, "Tidak Diketahui")
|
| 31 |
+
|
| 32 |
+
# Display the prediction
|
| 33 |
+
st.markdown("### 🧾 Hasil Prediksi")
|
| 34 |
+
st.write(f"Tingkat Stres yang Diprediksi: **{stress_level}**")
|
base_model_nurse_stress_15min.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9b13c38af23e81bf118c74240ddefeb02ce9344378e03e7821bbe396b519491a
|
| 3 |
+
size 43278906
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
joblib
|
| 3 |
+
numpy
|
| 4 |
+
pandas
|
| 5 |
+
pickle
|
| 6 |
+
pycaret
|