Spaces:
Sleeping
Sleeping
File size: 750 Bytes
cb1ecb5 4fdca24 cb1ecb5 4fdca24 cb1ecb5 4fdca24 cb1ecb5 4fdca24 cb1ecb5 de96aa5 cb1ecb5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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()
|