Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,14 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
-
import pandas as pd
|
| 4 |
-
|
| 5 |
-
# Load dataset (for normalization values)
|
| 6 |
-
df = pd.read_csv("updated_stroke_risk_dataset.csv")
|
| 7 |
-
|
| 8 |
-
# Compute mean and std from dataset (for normalization)
|
| 9 |
-
mu = df.drop(columns=["Stroke Risk (%)", "At Risk (Binary)", "Age"]).mean().values
|
| 10 |
-
sigma = df.drop(columns=["Stroke Risk (%)", "At Risk (Binary)", "Age"]).std().values
|
| 11 |
-
sigma = np.where(sigma == 0, 1, sigma) # Prevent division by zero
|
| 12 |
|
| 13 |
# Load trained model parameters (assumed to be saved as .npy file)
|
| 14 |
theta_final = np.load("theta_final.npy") # Save your trained theta and upload it to HF Spaces
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def predict_stroke_risk(*symptoms):
|
| 17 |
user_input = np.array([symptoms])
|
| 18 |
normalized_input = (user_input - mu) / sigma
|
|
@@ -39,4 +35,4 @@ demo = gr.Interface(
|
|
| 39 |
description="Check your stroke risk based on symptoms."
|
| 40 |
)
|
| 41 |
|
| 42 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# Load trained model parameters (assumed to be saved as .npy file)
|
| 5 |
theta_final = np.load("theta_final.npy") # Save your trained theta and upload it to HF Spaces
|
| 6 |
|
| 7 |
+
# Mean and standard deviation for normalization (precomputed from dataset)
|
| 8 |
+
mu = np.array([...]) # Replace with actual values
|
| 9 |
+
sigma = np.array([...]) # Replace with actual values
|
| 10 |
+
sigma = np.where(sigma == 0, 1, sigma) # Prevent division by zero
|
| 11 |
+
|
| 12 |
def predict_stroke_risk(*symptoms):
|
| 13 |
user_input = np.array([symptoms])
|
| 14 |
normalized_input = (user_input - mu) / sigma
|
|
|
|
| 35 |
description="Check your stroke risk based on symptoms."
|
| 36 |
)
|
| 37 |
|
| 38 |
+
demo.launch()
|