File size: 749 Bytes
4a628aa
 
cbde500
4a628aa
 
 
 
 
 
 
cbde500
4a628aa
 
 
cbde500
 
 
 
4a628aa
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
import numpy as np
import joblib

# Load model with joblib
model = joblib.load("random_forest_model.pkl")

st.title("AI Sleep State Detection")
st.markdown("Enter **angle** and **enmo** to predict the sleep state:")

angle = st.number_input("Angle", min_value=-360.0, max_value=360.0, step=0.1)
enmo = st.number_input("ENMO", min_value=0.0, max_value=10.0, step=0.0001, format="%.4f")

if st.button("Detect Sleep State"):
    # Normalize angle to be within 0–360
    normalized_angle = angle % 360

    input_data = np.array([[normalized_angle, enmo]])
    prediction = model.predict(input_data)[0]

    if prediction == 0:
        st.success("Sleep State: **Wakeup**")
    else:
        st.success("Sleep State: **Onset**")