Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,11 +41,20 @@ model = RandomForestClassifier(n_estimators=100, random_state=42)
|
|
| 41 |
model.fit(X_train, y_train)
|
| 42 |
|
| 43 |
# Define Prediction Function
|
| 44 |
-
def predict_diabetes(gender, age, hypertension, heart_disease, smoking_history, bmi,
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
prediction = model.predict(input_scaled)
|
| 48 |
-
|
|
|
|
| 49 |
|
| 50 |
# Define UI with Gradio
|
| 51 |
iface = gr.Interface(
|
|
|
|
| 41 |
model.fit(X_train, y_train)
|
| 42 |
|
| 43 |
# Define Prediction Function
|
| 44 |
+
def predict_diabetes(gender, age, hypertension, heart_disease, smoking_history, bmi, HbA1c, blood_glucose):
|
| 45 |
+
# Convert categorical inputs to numeric
|
| 46 |
+
gender_numeric = 1 if gender == "Male" else 0 # Encode 'Male' as 1, 'Female' as 0
|
| 47 |
+
|
| 48 |
+
# Prepare the input as a NumPy array
|
| 49 |
+
input_data = np.array([[gender_numeric, age, hypertension, heart_disease, smoking_history, bmi, HbA1c, blood_glucose]])
|
| 50 |
+
|
| 51 |
+
# Scale the input data
|
| 52 |
+
input_scaled = scaler.transform(input_data) # Ensure all values are numeric
|
| 53 |
+
|
| 54 |
+
# Make prediction
|
| 55 |
prediction = model.predict(input_scaled)
|
| 56 |
+
|
| 57 |
+
return "Diabetes Positive" if prediction[0] == 1 else "Diabetes Negative"
|
| 58 |
|
| 59 |
# Define UI with Gradio
|
| 60 |
iface = gr.Interface(
|