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()