Update app.py
Browse files
app.py
CHANGED
|
@@ -71,34 +71,49 @@ def calculate_metrics(age, sex, height_cm, weight_kg, wc_cm):
|
|
| 71 |
# BFP Category (ACE)
|
| 72 |
if sex.lower() == "female":
|
| 73 |
if bfp <= 13:
|
| 74 |
-
bfp_category = "Essential"
|
| 75 |
elif bfp <= 20:
|
| 76 |
bfp_category = "Athlete"
|
| 77 |
elif bfp <= 24:
|
| 78 |
-
bfp_category = "
|
| 79 |
elif bfp <= 31:
|
| 80 |
bfp_category = "Average"
|
| 81 |
else:
|
| 82 |
bfp_category = "Obese"
|
| 83 |
else:
|
| 84 |
if bfp <= 5:
|
| 85 |
-
bfp_category = "Essential"
|
| 86 |
elif bfp <= 13:
|
| 87 |
bfp_category = "Athlete"
|
| 88 |
elif bfp <= 17:
|
| 89 |
-
bfp_category = "
|
| 90 |
elif bfp <= 24:
|
| 91 |
bfp_category = "Average"
|
| 92 |
else:
|
| 93 |
bfp_category = "Obese"
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
return {
|
| 96 |
"BMI": round(bmi, 2),
|
| 97 |
"WHTR": round(whtr, 2),
|
| 98 |
"BFP": round(bfp, 2),
|
| 99 |
"LBM": round(lbm, 2),
|
| 100 |
"BMI_Category": bmi_category,
|
| 101 |
-
"BFP_Category": bfp_category
|
|
|
|
| 102 |
}
|
| 103 |
|
| 104 |
# Prediction function
|
|
|
|
| 71 |
# BFP Category (ACE)
|
| 72 |
if sex.lower() == "female":
|
| 73 |
if bfp <= 13:
|
| 74 |
+
bfp_category = "Essential fat"
|
| 75 |
elif bfp <= 20:
|
| 76 |
bfp_category = "Athlete"
|
| 77 |
elif bfp <= 24:
|
| 78 |
+
bfp_category = "Fit"
|
| 79 |
elif bfp <= 31:
|
| 80 |
bfp_category = "Average"
|
| 81 |
else:
|
| 82 |
bfp_category = "Obese"
|
| 83 |
else:
|
| 84 |
if bfp <= 5:
|
| 85 |
+
bfp_category = "Essential fat"
|
| 86 |
elif bfp <= 13:
|
| 87 |
bfp_category = "Athlete"
|
| 88 |
elif bfp <= 17:
|
| 89 |
+
bfp_category = "Fit"
|
| 90 |
elif bfp <= 24:
|
| 91 |
bfp_category = "Average"
|
| 92 |
else:
|
| 93 |
bfp_category = "Obese"
|
| 94 |
+
|
| 95 |
+
# Interpretation
|
| 96 |
+
if bfp_category=="Essential":
|
| 97 |
+
interpretation='Minimum fat required for basic physiological functions (e.g., hormone production, insulation). Females require higher essential fat due to reproductive functions.'
|
| 98 |
+
elif bfp_category=='Athletes':
|
| 99 |
+
interpretation='Typical for competitive athletes with high muscle mass and low fat (e.g., runners, bodybuilders).'
|
| 100 |
+
elif bfp_category=='Fit'
|
| 101 |
+
interpretation='Healthy range for active individuals who exercise regularly but aren’t competitive athletes.'
|
| 102 |
+
elif bfp_category=='Average'
|
| 103 |
+
interpretation='Common for the general population, still within healthy limits'
|
| 104 |
+
elif bfp_category=='Obese'
|
| 105 |
+
interpretation='Associated with increased health risks (e.g., diabetes, heart disease and other CVDs)'
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
DataAll
|
| 109 |
return {
|
| 110 |
"BMI": round(bmi, 2),
|
| 111 |
"WHTR": round(whtr, 2),
|
| 112 |
"BFP": round(bfp, 2),
|
| 113 |
"LBM": round(lbm, 2),
|
| 114 |
"BMI_Category": bmi_category,
|
| 115 |
+
"BFP_Category": bfp_category,
|
| 116 |
+
"Interpretation": interpretation
|
| 117 |
}
|
| 118 |
|
| 119 |
# Prediction function
|