Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| # β Load the model correctly using joblib | |
| model = joblib.load("log_reg_model.pkl") | |
| # Define prediction function | |
| def predict_sleep(step: float, hour: float): | |
| input_data = np.array([[step, hour]]) | |
| prediction = model.predict(input_data)[0] | |
| return "Sleep Onset" if prediction == 1 else "Wakeup" | |
| # Gradio interface | |
| iface = gr.Interface( | |
| fn=predict_sleep, | |
| inputs=[ | |
| gr.Number(label="Step Count"), | |
| gr.Number(label="Hour (0β23)") | |
| ], | |
| outputs=gr.Text(label="Prediction"), | |
| title="Sleep Prediction (Onset/Wakeup)", | |
| description="Enter step count and hour to predict whether it's sleep onset or wakeup." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |