import streamlit as st import numpy as np import pandas as pd import joblib import matplotlib.pyplot as plt import seaborn as sns from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay # Load model model = joblib.load("random_forest_model.pkl") # Page configuration st.set_page_config(page_title="Sleep Detector ", layout="wide") # Custom CSS st.markdown(""" """, unsafe_allow_html=True) st.title("😴 AI Sleep Detection System") st.markdown("Navigate the Sleep Detection project through each CRISP-ML(Q) step.") st.header("🤖 Model Prediction") angle = st.number_input("📐 Enter Angle (0–360°)", 0.0, 360.0, step=0.1) enmo = st.number_input("📊 Enter ENMO (0.0000–10.0000)", 0.0, 10.0, step=0.0001, format="%.4f") if st.button("🔍 Predict Sleep State"): input_data = np.array([[angle, enmo]]) prediction = model.predict(input_data)[0] confidence = model.predict_proba(input_data)[0][prediction] * 100 label = "🌞 Wakeup" if prediction == 0 else "🌙 Sleep Onset" color = "#ffcc00" if prediction == 0 else "#6699ff" st.markdown(f"