Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -12,81 +12,66 @@ short_description: Streamlit app with BodyFat (%) predictor
|
|
| 12 |
license: mit
|
| 13 |
---
|
| 14 |
|
| 15 |
-
# ๐งโโ๏ธ
|
| 16 |
|
| 17 |
-
This project
|
| 18 |
-
The implementation follows the original **ML Olympiad โ Predicting Wellness** competition setup.
|
| 19 |
|
| 20 |
---
|
| 21 |
|
| 22 |
## ๐ Project Overview
|
| 23 |
|
| 24 |
-
The
|
| 25 |
|
| 26 |
-
- Predict **body density**
|
| 27 |
-
-
|
| 28 |
-
- Provide
|
| 29 |
-
-
|
| 30 |
|
| 31 |
-
This
|
| 32 |
|
| 33 |
---
|
| 34 |
|
| 35 |
## ๐ Dataset & Target
|
| 36 |
|
| 37 |
- **Input features:**
|
| 38 |
-
Anthropometric measurements such as age,
|
| 39 |
|
| 40 |
-
- **Target variable
|
| 41 |
-
`Density` (body density)
|
| 42 |
|
| 43 |
-
|
| 44 |
-
`BodyFat (%)` calculated using the **Siri equation**
|
| 45 |
|
| 46 |
---
|
| 47 |
|
| 48 |
-
##
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
This formula is widely used in body composition analysis and was applied **exactly as defined in the competition**.
|
| 58 |
|
| 59 |
---
|
| 60 |
|
| 61 |
-
##
|
| 62 |
-
|
| 63 |
-
- Human body density typically lies in a **very narrow range (โ 0.95โ1.10)**
|
| 64 |
-
- Small prediction errors in density can lead to **large changes in body fat percentage**
|
| 65 |
-
- In some cases, valid inputs may result in **non-physiological values (e.g. negative body fat)**
|
| 66 |
|
| 67 |
-
|
| 68 |
-
- Raw body fat values are **calculated transparently**
|
| 69 |
-
- A **warning** is shown if predicted density is outside the typical human range
|
| 70 |
-
- For display purposes only, body fat is **clipped to 0โ60%**
|
| 71 |
-
- Raw values remain visible for transparency
|
| 72 |
|
| 73 |
-
|
|
|
|
| 74 |
|
| 75 |
-
|
|
|
|
| 76 |
|
| 77 |
-
|
|
|
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
- Handles multicollinearity between highly correlated body measurements
|
| 82 |
-
- Performs well on small datasets
|
| 83 |
-
- Produces stable and interpretable results
|
| 84 |
-
|
| 85 |
-
- **Feature Engineering (if used by the model):**
|
| 86 |
-
- **Waist-to-Hip Ratio:** `Abdomen / Hip`
|
| 87 |
-
- **Body Index (BMI, imperial):** `703 ร Weight / Heightยฒ`
|
| 88 |
|
| 89 |
-
|
| 90 |
|
| 91 |
---
|
| 92 |
|
|
@@ -94,13 +79,12 @@ Only engineered features that were present during training are computed in the a
|
|
| 94 |
|
| 95 |
| Measurement | Unit |
|
| 96 |
|------------|------|
|
| 97 |
-
| Height | **Centimeters (cm)**
|
| 98 |
| Weight | **Pounds (lbs)** |
|
| 99 |
-
|
|
| 100 |
-
|
|
| 101 |
-
| Output BodyFat | Percentage (%) |
|
| 102 |
|
| 103 |
-
โ ๏ธ Correct units are
|
| 104 |
|
| 105 |
---
|
| 106 |
|
|
@@ -108,33 +92,44 @@ Only engineered features that were present during training are computed in the a
|
|
| 108 |
|
| 109 |
### ๐น Single Prediction
|
| 110 |
- Interactive form with realistic input ranges
|
| 111 |
-
- Automatic unit conversion
|
| 112 |
-
-
|
| 113 |
-
-
|
| 114 |
-
- Display of
|
| 115 |
|
| 116 |
### ๐น Batch Prediction (CSV)
|
| 117 |
-
- Upload
|
| 118 |
- Automatic feature alignment
|
| 119 |
-
- Download predictions as CSV
|
| 120 |
|
| 121 |
---
|
| 122 |
|
| 123 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
-
|
| 126 |
-
Predictions are for **educational and demonstration purposes only**.
|
| 127 |
|
| 128 |
---
|
| 129 |
|
| 130 |
## ๐งช Limitations
|
| 131 |
|
| 132 |
- Small dataset size limits generalization
|
| 133 |
-
-
|
| 134 |
-
-
|
| 135 |
-
-
|
| 136 |
|
| 137 |
-
These limitations are **explicitly
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
---
|
| 140 |
|
|
@@ -148,7 +143,7 @@ These limitations are **explicitly shown and explained** in the app.
|
|
| 148 |
|
| 149 |
---
|
| 150 |
|
| 151 |
-
## ๐
|
| 152 |
|
| 153 |
โโโ app.py
|
| 154 |
โโโ ridge_model.pkl
|
|
@@ -162,5 +157,7 @@ Code kopieren
|
|
| 162 |
|
| 163 |
## โ
Conclusion
|
| 164 |
|
| 165 |
-
This project
|
| 166 |
-
By
|
|
|
|
|
|
|
|
|
| 12 |
license: mit
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# ๐งโโ๏ธ Body Density Predictor โ Ridge Regression
|
| 16 |
|
| 17 |
+
This project presents a **machine learning regression application** that predicts **human body density** from anthropometric measurements using a **Ridge Regression** model.
|
| 18 |
+
The implementation follows the original **ML Olympiad โ Predicting Wellness** competition setup, where **body density** is the primary target variable.
|
| 19 |
|
| 20 |
---
|
| 21 |
|
| 22 |
## ๐ Project Overview
|
| 23 |
|
| 24 |
+
The main objectives of this project are:
|
| 25 |
|
| 26 |
+
- Predict **body density (Density)** from physical body measurements
|
| 27 |
+
- Build a **stable and interpretable regression model** for a small dataset
|
| 28 |
+
- Provide an **interactive Streamlit demo** for single and batch predictions
|
| 29 |
+
- Clearly communicate model assumptions and limitations
|
| 30 |
|
| 31 |
+
This project is intended for **educational and portfolio purposes**.
|
| 32 |
|
| 33 |
---
|
| 34 |
|
| 35 |
## ๐ Dataset & Target
|
| 36 |
|
| 37 |
- **Input features:**
|
| 38 |
+
Anthropometric measurements such as age, height, weight, and body circumferences (neck, chest, abdomen, hip, thigh, etc.)
|
| 39 |
|
| 40 |
+
- **Target variable:**
|
| 41 |
+
`Density` (human body density)
|
| 42 |
|
| 43 |
+
The model is trained **directly on Density**, without predicting body fat percentage.
|
|
|
|
| 44 |
|
| 45 |
---
|
| 46 |
|
| 47 |
+
## ๐ง Model Description
|
| 48 |
|
| 49 |
+
- **Model type:** Ridge Regression (L2-regularized linear regression)
|
| 50 |
+
- **Reason for model choice:**
|
| 51 |
+
- Handles strong multicollinearity between body measurements
|
| 52 |
+
- Performs well on small datasets
|
| 53 |
+
- Produces stable and smooth predictions
|
| 54 |
+
- Easy to interpret and deploy
|
|
|
|
|
|
|
| 55 |
|
| 56 |
---
|
| 57 |
|
| 58 |
+
## ๐งฎ Feature Engineering
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
Only features that were used during training are applied in the app:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
- **Waist-to-Hip Ratio:**
|
| 63 |
+
Waist_hip = Abdomen / Hip
|
| 64 |
|
| 65 |
+
markdown
|
| 66 |
+
Code kopieren
|
| 67 |
|
| 68 |
+
- **Body Index (BMI, imperial units):**
|
| 69 |
+
Body_Index = 703 ร Weight / Heightยฒ
|
| 70 |
|
| 71 |
+
yaml
|
| 72 |
+
Code kopieren
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
Engineered features are calculated **only if required by the trained model**.
|
| 75 |
|
| 76 |
---
|
| 77 |
|
|
|
|
| 79 |
|
| 80 |
| Measurement | Unit |
|
| 81 |
|------------|------|
|
| 82 |
+
| Height | **Centimeters (cm)** (converted internally to inches) |
|
| 83 |
| Weight | **Pounds (lbs)** |
|
| 84 |
+
| Body circumferences | **Inches** |
|
| 85 |
+
| Model output | **Density** (unitless) |
|
|
|
|
| 86 |
|
| 87 |
+
โ ๏ธ Correct units are essential for meaningful predictions.
|
| 88 |
|
| 89 |
---
|
| 90 |
|
|
|
|
| 92 |
|
| 93 |
### ๐น Single Prediction
|
| 94 |
- Interactive form with realistic input ranges
|
| 95 |
+
- Automatic unit conversion (cm โ inches)
|
| 96 |
+
- Feature engineering and alignment
|
| 97 |
+
- Density prediction with plausibility warnings
|
| 98 |
+
- Display of final model inputs
|
| 99 |
|
| 100 |
### ๐น Batch Prediction (CSV)
|
| 101 |
+
- Upload CSV files with required feature columns
|
| 102 |
- Automatic feature alignment
|
| 103 |
+
- Download predictions as a CSV file
|
| 104 |
|
| 105 |
---
|
| 106 |
|
| 107 |
+
## โ ๏ธ Important Notes on Predictions
|
| 108 |
+
|
| 109 |
+
- Human body density typically lies within a **very narrow range (โ 0.95 โ 1.10)**
|
| 110 |
+
- Predictions outside this range may indicate:
|
| 111 |
+
- Unrealistic input values
|
| 112 |
+
- Inputs outside the training distribution
|
| 113 |
|
| 114 |
+
The app provides **warnings** when predicted density values fall outside the typical physiological range.
|
|
|
|
| 115 |
|
| 116 |
---
|
| 117 |
|
| 118 |
## ๐งช Limitations
|
| 119 |
|
| 120 |
- Small dataset size limits generalization
|
| 121 |
+
- Linear regression may oversimplify complex physiological relationships
|
| 122 |
+
- Predictions may be unreliable for extreme or unrealistic input values
|
| 123 |
+
- The model is not intended for medical or clinical use
|
| 124 |
|
| 125 |
+
These limitations are **explicitly communicated in the app interface**.
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
## ๐ซ Disclaimer
|
| 130 |
+
|
| 131 |
+
This application is **not a medical device**.
|
| 132 |
+
All predictions are provided for **educational and demonstration purposes only** and must not be used for health diagnosis or treatment decisions.
|
| 133 |
|
| 134 |
---
|
| 135 |
|
|
|
|
| 143 |
|
| 144 |
---
|
| 145 |
|
| 146 |
+
## ๐ Repository Structure
|
| 147 |
|
| 148 |
โโโ app.py
|
| 149 |
โโโ ridge_model.pkl
|
|
|
|
| 157 |
|
| 158 |
## โ
Conclusion
|
| 159 |
|
| 160 |
+
This project demonstrates a complete and transparent machine learning pipeline for predicting **body density** using Ridge Regression.
|
| 161 |
+
By focusing directly on the competition target variable and avoiding unnecessary post-processing, the application provides **stable, interpretable, and scientifically consistent predictions**, making it well suited as a portfolio and learning project.
|
| 162 |
+
|
| 163 |
+
---
|