Spaces:
Sleeping
Sleeping
Delete app (2).py
Browse files- app (2).py +0 -53
app (2).py
DELETED
|
@@ -1,53 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import numpy as np
|
| 3 |
-
import pandas as pd
|
| 4 |
-
import joblib
|
| 5 |
-
import matplotlib.pyplot as plt
|
| 6 |
-
import seaborn as sns
|
| 7 |
-
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
|
| 8 |
-
|
| 9 |
-
# Load model
|
| 10 |
-
model = joblib.load("random_forest_model.pkl")
|
| 11 |
-
|
| 12 |
-
# Page configuration
|
| 13 |
-
st.set_page_config(page_title="Sleep Detector ", layout="wide")
|
| 14 |
-
|
| 15 |
-
# Custom CSS
|
| 16 |
-
st.markdown("""
|
| 17 |
-
<style>
|
| 18 |
-
.main {
|
| 19 |
-
background-color: #f4f6f9;
|
| 20 |
-
font-family: 'Segoe UI', sans-serif;
|
| 21 |
-
}
|
| 22 |
-
h1, h2, h3 {
|
| 23 |
-
color: #333;
|
| 24 |
-
}
|
| 25 |
-
</style>
|
| 26 |
-
""", unsafe_allow_html=True)
|
| 27 |
-
|
| 28 |
-
st.title("π΄ AI Sleep Detection System")
|
| 29 |
-
st.markdown("Navigate the Sleep Detection project through each CRISP-ML(Q) step.")
|
| 30 |
-
|
| 31 |
-
st.header("π€ Model Prediction")
|
| 32 |
-
|
| 33 |
-
angle = st.number_input("π Enter Angle (0β360Β°)", 0.0, 360.0, step=0.1)
|
| 34 |
-
enmo = st.number_input("π Enter ENMO (0.0000β10.0000)", 0.0, 10.0, step=0.0001, format="%.4f")
|
| 35 |
-
|
| 36 |
-
if st.button("π Predict Sleep State"):
|
| 37 |
-
input_data = np.array([[angle, enmo]])
|
| 38 |
-
prediction = model.predict(input_data)[0]
|
| 39 |
-
confidence = model.predict_proba(input_data)[0][prediction] * 100
|
| 40 |
-
|
| 41 |
-
label = "π Wakeup" if prediction == 0 else "π Sleep Onset"
|
| 42 |
-
color = "#ffcc00" if prediction == 0 else "#6699ff"
|
| 43 |
-
|
| 44 |
-
st.markdown(f"<h3 style='color:{color}'>π§ Prediction: {label}</h3>", unsafe_allow_html=True)
|
| 45 |
-
st.markdown(f"**Confidence Score:** `{confidence:.2f}%`")
|
| 46 |
-
|
| 47 |
-
st.subheader("π Input Summary")
|
| 48 |
-
st.json({
|
| 49 |
-
"Angle": round(angle, 2),
|
| 50 |
-
"ENMO": round(enmo, 4),
|
| 51 |
-
"Predicted State": "Wakeup" if prediction == 0 else "Sleep Onset",
|
| 52 |
-
"Confidence (%)": round(confidence, 2)
|
| 53 |
-
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|