Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
import joblib
|
3 |
-
import numpy as np
|
4 |
|
5 |
# Load the model and scaler
|
6 |
model = joblib.load('logistic_regression_model.pkl')
|
7 |
scaler = joblib.load('scaler.pkl')
|
8 |
|
|
|
|
|
|
|
|
|
9 |
def initial_risk_check(features):
|
10 |
# Scale and predict risk based on the features
|
11 |
features_scaled = scaler.transform([features])
|
12 |
prediction = model.predict_proba(features_scaled)[:, 1]
|
13 |
|
14 |
-
# Define risk thresholds
|
15 |
-
high_risk_threshold = 0.75
|
16 |
-
moderate_risk_threshold = 0.25
|
17 |
-
|
18 |
# Determine risk level and recommendation
|
19 |
if prediction >= high_risk_threshold:
|
20 |
return "High risk. Please consult a doctor immediately.", prediction
|
|
|
1 |
import gradio as gr
|
2 |
import joblib
|
3 |
+
import numpy as np
|
4 |
|
5 |
# Load the model and scaler
|
6 |
model = joblib.load('logistic_regression_model.pkl')
|
7 |
scaler = joblib.load('scaler.pkl')
|
8 |
|
9 |
+
# Define risk thresholds globally
|
10 |
+
high_risk_threshold = 0.75
|
11 |
+
moderate_risk_threshold = 0.25
|
12 |
+
|
13 |
def initial_risk_check(features):
|
14 |
# Scale and predict risk based on the features
|
15 |
features_scaled = scaler.transform([features])
|
16 |
prediction = model.predict_proba(features_scaled)[:, 1]
|
17 |
|
|
|
|
|
|
|
|
|
18 |
# Determine risk level and recommendation
|
19 |
if prediction >= high_risk_threshold:
|
20 |
return "High risk. Please consult a doctor immediately.", prediction
|