hackerbyhobby commited on
Commit
7608698
·
unverified ·
1 Parent(s): e4a6aba

updated app2

Browse files
Files changed (1) hide show
  1. app.py +2 -19
app.py CHANGED
@@ -48,22 +48,8 @@ def predict_heart_failure(age_category, alcohol_drinkers, chest_scan, covid_posi
48
  print(f"Prediction: {prediction}")
49
  return "High likelihood of heart failure" if prediction == 1 else "Low likelihood of heart failure"
50
 
51
- def predict_heart_failure(age_category, alcohol_drinkers, chest_scan, covid_positive, physical_health_days, mental_health_days, sleep_hours, bmi):
52
- # Prepare input data
53
- input_data = {feature: 0 for feature in feature_names}
54
- input_data[f"AgeCategory_{age_category}"] = 1
55
- input_data[f"AlcoholDrinkers_{alcohol_drinkers}"] = 1
56
- input_data[f"ChestScan_{chest_scan}"] = 1
57
- input_data[f"CovidPos_{covid_positive}"] = 1
58
- input_data["PhysicalHealthDays"] = physical_health_days
59
- input_data["MentalHealthDays"] = mental_health_days
60
- input_data["SleepHours"] = sleep_hours
61
- input_data["BMI"] = bmi
62
-
63
- # Convert to DataFrame
64
- input_df = pd.DataFrame([input_data])
65
 
66
- # Debugging: Print the input DataFrame
67
  print("Input DataFrame passed to the model:")
68
  print(input_df)
69
 
@@ -73,14 +59,11 @@ def predict_heart_failure(age_category, alcohol_drinkers, chest_scan, covid_posi
73
  print(probs)
74
 
75
  # Adjust threshold and make predictions
76
- threshold = 0.4
77
  predictions = (probs[:, 1] >= threshold).astype(int)
78
  print("Predictions with adjusted threshold:")
79
  print(predictions)
80
 
81
- # Return prediction
82
- return "High likelihood of heart failure" if predictions[0] == 1 else "Low likelihood of heart failure"
83
-
84
 
85
  # Define Gradio inputs
86
  gradio_inputs = [
 
48
  print(f"Prediction: {prediction}")
49
  return "High likelihood of heart failure" if prediction == 1 else "Low likelihood of heart failure"
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ def debug_model_input(input_df, model, threshold=0.5):
53
  print("Input DataFrame passed to the model:")
54
  print(input_df)
55
 
 
59
  print(probs)
60
 
61
  # Adjust threshold and make predictions
 
62
  predictions = (probs[:, 1] >= threshold).astype(int)
63
  print("Predictions with adjusted threshold:")
64
  print(predictions)
65
 
66
+ debug_model_input(test_df, model, threshold=0.4)
 
 
67
 
68
  # Define Gradio inputs
69
  gradio_inputs = [