File size: 791 Bytes
a4161d5
 
 
ef2acb6
 
1c28dea
ef2acb6
a4161d5
ef2acb6
 
 
 
 
 
 
 
 
a4161d5
ef2acb6
 
a4161d5
ef2acb6
c69ea33
ef2acb6
a4161d5
ef2acb6
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
import gradio as gr
import numpy as np

# Load trained model parameters
theta = np.load("theta_final.npy")

# Define prediction function
def predict_stroke_risk(*symptoms):
    symptoms_array = np.array(symptoms).astype(float)
    risk = np.dot(symptoms_array, theta) * 100  # Convert to percentage
    return round(risk, 2)

# Define UI
symptoms_list = ["Symptom 1", "Symptom 2", "Symptom 3", "Symptom 4", "Symptom 5"]
with gr.Blocks() as demo:
    gr.Markdown("# 🏥 Stroke Risk Predictor 🚑")
    gr.Markdown("Select symptoms and get your stroke risk percentage.")

    checkboxes = [gr.Checkbox(label=s) for s in symptoms_list]
    submit = gr.Button("Predict")

    output = gr.Textbox(label="Stroke Risk %")

    submit.click(predict_stroke_risk, checkboxes, output)

demo.launch()