| import gradio as gr |
| import numpy as np |
|
|
| |
| theta = np.load("theta_final.npy") |
|
|
| |
| def predict_stroke_risk(*symptoms): |
| symptoms_array = np.array(symptoms).astype(float) |
| risk = np.dot(symptoms_array, theta) * 100 |
| return round(risk, 2) |
|
|
| |
| 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() |
|
|