Spaces:
Sleeping
Sleeping
File size: 4,368 Bytes
37c8690 4f14e4e 1902da4 37c8690 4f14e4e 37c8690 4f14e4e 37c8690 d7e3212 37c8690 d7e3212 37c8690 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 1902da4 d7e3212 1902da4 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 1902da4 22b94e4 1902da4 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 d7e3212 22b94e4 1902da4 22b94e4 1902da4 d7e3212 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | ---
title: BodyFatPredictor
emoji: ๐งโโ๏ธ
colorFrom: red
colorTo: red
sdk: docker
app_port: 8501
tags:
- streamlit
pinned: false
short_description: Streamlit app with BodyFat (%) predictor
license: mit
---
# ๐งโโ๏ธ Body Density Predictor โ Ridge Regression
This project presents a **machine learning regression application** that predicts **human body density** from anthropometric measurements using a **Ridge Regression** model.
The implementation follows the original **ML Olympiad โ Predicting Wellness** competition setup, where **body density** is the primary target variable.
---
## ๐ Project Overview
The main objectives of this project are:
- Predict **body density (Density)** from physical body measurements
- Build a **stable and interpretable regression model** for a small dataset
- Provide an **interactive Streamlit demo** for single and batch predictions
- Clearly communicate model assumptions and limitations
This project is intended for **educational and portfolio purposes**.
---
## ๐ Dataset & Target
- **Input features:**
Anthropometric measurements such as age, height, weight, and body circumferences (neck, chest, abdomen, hip, thigh, etc.)
- **Target variable:**
`Density` (human body density)
The model is trained **directly on Density**, without predicting body fat percentage.
---
## ๐ง Model Description
- **Model type:** Ridge Regression (L2-regularized linear regression)
- **Reason for model choice:**
- Handles strong multicollinearity between body measurements
- Performs well on small datasets
- Produces stable and smooth predictions
- Easy to interpret and deploy
---
## ๐งฎ Feature Engineering
Only features that were used during training are applied in the app:
- **Waist-to-Hip Ratio:**
Waist_hip = Abdomen / Hip
markdown
Code kopieren
- **Body Index (BMI, imperial units):**
Body_Index = 703 ร Weight / Heightยฒ
yaml
Code kopieren
Engineered features are calculated **only if required by the trained model**.
---
## ๐ Units & Input Conventions
| Measurement | Unit |
|------------|------|
| Height | **Centimeters (cm)** (converted internally to inches) |
| Weight | **Pounds (lbs)** |
| Body circumferences | **Inches** |
| Model output | **Density** (unitless) |
โ ๏ธ Correct units are essential for meaningful predictions.
---
## ๐ฅ๏ธ Application Features
### ๐น Single Prediction
- Interactive form with realistic input ranges
- Automatic unit conversion (cm โ inches)
- Feature engineering and alignment
- Density prediction with plausibility warnings
- Display of final model inputs
### ๐น Batch Prediction (CSV)
- Upload CSV files with required feature columns
- Automatic feature alignment
- Download predictions as a CSV file
---
## โ ๏ธ Important Notes on Predictions
- Human body density typically lies within a **very narrow range (โ 0.95 โ 1.10)**
- Predictions outside this range may indicate:
- Unrealistic input values
- Inputs outside the training distribution
The app provides **warnings** when predicted density values fall outside the typical physiological range.
---
## ๐งช Limitations
- Small dataset size limits generalization
- Linear regression may oversimplify complex physiological relationships
- Predictions may be unreliable for extreme or unrealistic input values
- The model is not intended for medical or clinical use
These limitations are **explicitly communicated in the app interface**.
---
## ๐ซ Disclaimer
This application is **not a medical device**.
All predictions are provided for **educational and demonstration purposes only** and must not be used for health diagnosis or treatment decisions.
---
## ๐งฐ Tech Stack
- Python
- pandas, NumPy
- scikit-learn
- Streamlit
- joblib
---
## ๐ Repository Structure
โโโ app.py
โโโ ridge_model.pkl
โโโ requirements.txt
โโโ README.md
yaml
Code kopieren
---
## โ
Conclusion
This project demonstrates a complete and transparent machine learning pipeline for predicting **body density** using Ridge Regression.
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.
--- |