Snigs98 commited on
Commit
83d0abc
·
verified ·
1 Parent(s): ebdfef3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
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, HbA1c_level, blood_glucose_level):
45
- input_data = np.array([[gender, age, hypertension, heart_disease, smoking_history, bmi, HbA1c_level, blood_glucose_level]])
46
- input_scaled = scaler.transform(input_data)
 
 
 
 
 
 
 
 
47
  prediction = model.predict(input_scaled)
48
- return "Diabetic" if prediction[0] == 1 else "Non-Diabetic"
 
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(