{"id":19056328,"url":"https://github.com/chanmeng666/bodyfat-estimation-mlp","last_synced_at":"2026-05-08T04:03:50.688Z","repository":{"id":258131005,"uuid":"867928141","full_name":"ChanMeng666/bodyfat-estimation-mlp","owner":"ChanMeng666","description":"【This repo runs on caffeine and stars - fuel us up! ⭐️】A deep learning project implementing neural network models to accurately predict body fat percentage from anthropometric measurements. Features both comprehensive and reduced-input models, with detailed analysis of feature importance and model performance.","archived":false,"fork":false,"pushed_at":"2025-01-15T04:06:23.000Z","size":5822,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-15T06:10:46.491Z","etag":null,"topics":["body-composition","data-science-biometrics","deep-learning","feature-analysis","health-tech","keras","neural-networks","predictive-modeling","tensorflow"],"latest_commit_sha":null,"homepage":"https://github.com/ChanMeng666/bodyfat-estimation-mlp/blob/main/Assignment2_Part3_(i).ipynb","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChanMeng666.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"chanmeng66u","thanks_dev":null,"custom":null}},"created_at":"2024-10-05T03:10:28.000Z","updated_at":"2025-01-15T04:06:24.000Z","dependencies_parsed_at":"2025-01-07T11:24:47.017Z","dependency_job_id":"725c6528-ee16-434d-be90-c5c1aaee6be3","html_url":"https://github.com/ChanMeng666/bodyfat-estimation-mlp","commit_stats":null,"previous_names":["chanmeng666/bodyfat-estimation-mlp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanMeng666%2Fbodyfat-estimation-mlp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanMeng666%2Fbodyfat-estimation-mlp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanMeng666%2Fbodyfat-estimation-mlp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanMeng666%2Fbodyfat-estimation-mlp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChanMeng666","download_url":"https://codeload.github.com/ChanMeng666/bodyfat-estimation-mlp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240112365,"owners_count":19749634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["body-composition","data-science-biometrics","deep-learning","feature-analysis","health-tech","keras","neural-networks","predictive-modeling","tensorflow"],"created_at":"2024-11-08T23:49:06.268Z","updated_at":"2026-05-08T04:03:50.679Z","avatar_url":"https://github.com/ChanMeng666.png","language":"Jupyter Notebook","funding_links":["https://buymeacoffee.com/chanmeng66u"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\n\n[![Project Banner](./figures/correlation_heatmap.png)](#)\n\n# Body Fat Estimation Neural Network\u003cbr/\u003e\u003ch3\u003eMulti-Layer Perceptron for Anthropometric Body Fat Prediction\u003c/h3\u003e\n\nA machine learning project that uses neural network architectures to predict body fat percentage from anthropometric measurements.\u003cbr/\u003e\nFeatures a comprehensive seven-phase analysis pipeline, intelligent feature selection, and pre-trained models achieving **R² scores exceeding 0.97**.\n\n[Live Demo](https://huggingface.co/ChanMeng666/bodyfat-estimation-mlp) · [Issues](https://github.com/ChanMeng666/bodyfat-estimation-mlp/issues)\n\n\u003cbr/\u003e\n\n\u003c!-- SHIELD GROUP --\u003e\n[![](https://img.shields.io/badge/python-3.7+-3670A0?style=flat-square\u0026logo=python\u0026logoColor=white)](https://python.org/)\n[![](https://img.shields.io/badge/tensorflow-2.0+-FF6F00?style=flat-square\u0026logo=tensorflow\u0026logoColor=white)](https://tensorflow.org/)\n[![](https://img.shields.io/badge/jupyter-notebook-F37626?style=flat-square\u0026logo=jupyter\u0026logoColor=white)](https://jupyter.org/)\n[![](https://img.shields.io/badge/license-MIT-white?labelColor=black\u0026style=flat-square)](LICENSE)\n[![](https://img.shields.io/github/stars/ChanMeng666/bodyfat-estimation-mlp?color=ffcb47\u0026labelColor=black\u0026style=flat-square)](https://github.com/ChanMeng666/bodyfat-estimation-mlp/stargazers)\n[![](https://img.shields.io/github/forks/ChanMeng666/bodyfat-estimation-mlp?color=8ae8ff\u0026labelColor=black\u0026style=flat-square)](https://github.com/ChanMeng666/bodyfat-estimation-mlp/forks)\n\n\u003c/div\u003e\n\n## Project Showcase\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"./figures/correlation_with_bodyfat.png\" alt=\"Feature Correlation Analysis\" width=\"800\"/\u003e\n  \u003cp\u003e\u003cem\u003eFeature Correlation Analysis — Identifying Key Anthropometric Predictors\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"./figures/correlation_heatmap.png\" alt=\"Correlation Heatmap\" width=\"600\"/\u003e\n  \u003cp\u003e\u003cem\u003eCorrelation Matrix — Understanding Feature Relationships\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n## Model Performance\n\n\u003cdiv align=\"center\"\u003e\n\n| Model Type | Hidden Neurons | R² Score | MSE | Features Used |\n|------------|----------------|----------|-----|---------------|\n| **Full Model** | 20 | **0.9724** | 1.9250 | All 14 features |\n| **Optimized Model** | 5 | **0.9950** | 0.2340 | Selected 9 features |\n\n\u003c/div\u003e\n\n### Performance Comparison\n\n\u003cdiv align=\"center\"\u003e\n\n| Metric | Full Model (20 neurons) | Optimized Model (5 neurons) | Improvement |\n|--------|-------------------------|------------------------------|-------------|\n| R² Score | 0.9724 | **0.9950** | +2.3% |\n| MSE | 1.9250 | **0.2340** | -87.8% |\n| Features | 14 | **9** | -35.7% |\n| Complexity | High | **Low** | Simplified |\n\n\u003c/div\u003e\n\n### Feature Importance\n\n1. **Body Density** (r = -0.99) — Primary physiological indicator\n2. **Abdomen** (r = 0.81) — Core body composition measurement\n3. **Chest** (r = 0.70) — Upper body muscle/fat distribution\n4. **Hip** (r = 0.63) — Lower body composition indicator\n5. **Weight** (r = 0.61) — Overall body mass contribution\n\n## Tech Stack\n\n\u003cdiv align=\"center\"\u003e\n  \u003ctable\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" width=\"96\"\u003e\n        \u003cimg src=\"https://cdn.simpleicons.org/python\" width=\"48\" height=\"48\" alt=\"Python\" /\u003e\n        \u003cbr\u003ePython 3.7+\n      \u003c/td\u003e\n      \u003ctd align=\"center\" width=\"96\"\u003e\n        \u003cimg src=\"https://cdn.simpleicons.org/tensorflow\" width=\"48\" height=\"48\" alt=\"TensorFlow\" /\u003e\n        \u003cbr\u003eTensorFlow 2.0+\n      \u003c/td\u003e\n      \u003ctd align=\"center\" width=\"96\"\u003e\n        \u003cimg src=\"https://cdn.simpleicons.org/keras\" width=\"48\" height=\"48\" alt=\"Keras\" /\u003e\n        \u003cbr\u003eKeras\n      \u003c/td\u003e\n      \u003ctd align=\"center\" width=\"96\"\u003e\n        \u003cimg src=\"https://cdn.simpleicons.org/pandas\" width=\"48\" height=\"48\" alt=\"Pandas\" /\u003e\n        \u003cbr\u003ePandas\n      \u003c/td\u003e\n      \u003ctd align=\"center\" width=\"96\"\u003e\n        \u003cimg src=\"https://cdn.simpleicons.org/numpy\" width=\"48\" height=\"48\" alt=\"NumPy\" /\u003e\n        \u003cbr\u003eNumPy\n      \u003c/td\u003e\n      \u003ctd align=\"center\" width=\"96\"\u003e\n        \u003cimg src=\"https://cdn.simpleicons.org/jupyter\" width=\"48\" height=\"48\" alt=\"Jupyter\" /\u003e\n        \u003cbr\u003eJupyter\n      \u003c/td\u003e\n      \u003ctd align=\"center\" width=\"96\"\u003e\n        \u003cimg src=\"https://cdn.simpleicons.org/scikitlearn\" width=\"48\" height=\"48\" alt=\"Scikit-learn\" /\u003e\n        \u003cbr\u003eScikit-learn\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/table\u003e\n\u003c/div\u003e\n\n- **Deep Learning**: TensorFlow 2.0+ with Keras high-level API\n- **Data Science**: NumPy for numerical computing, Pandas for data manipulation\n- **Machine Learning**: Scikit-learn for preprocessing and evaluation metrics\n- **Visualization**: Matplotlib and Seaborn for publication-quality plots\n- **Interactive Analysis**: Jupyter Notebook for reproducible research\n\n## Getting Started\n\n### Prerequisites\n\n- **Python 3.7+** ([Download](https://python.org/downloads/))\n- **pip** package manager (included with Python)\n- **Git** ([Download](https://git-scm.com/))\n\n### Installation\n\n**1. Clone the repository**\n\n```bash\ngit clone https://github.com/ChanMeng666/bodyfat-estimation-mlp.git\ncd bodyfat-estimation-mlp\n```\n\n**2. Create virtual environment (recommended)**\n\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n**3. Install dependencies**\n\n```bash\npip install -r requirements.txt\n```\n\n**4. Launch Jupyter Notebook**\n\n```bash\njupyter notebook\n```\n\n**5. Run the analysis**\n\nOpen notebooks sequentially from the `notebooks/` directory:\n\n| Notebook | Description |\n|----------|-------------|\n| `01_qualitative_analysis.ipynb` | Visual exploration of feature relationships |\n| `02_network_performance.ipynb` | Hyperparameter tuning and architecture optimization |\n| `03_correlation_analysis.ipynb` | Statistical significance testing |\n| `04_reduced_input_model.ipynb` | Feature selection and reduced model development |\n| `05_sensitivity_analysis.ipynb` | Feature importance quantification |\n| `06_performance_comparison.ipynb` | Cross-model validation and evaluation |\n| `07_summary_and_conclusions.ipynb` | Summary and clinical implications |\n\n## Usage\n\n### Quick Prediction\n\n\u003e **Important:** The model requires MinMaxScaler preprocessing. See [MODEL_USAGE_GUIDE.md](MODEL_USAGE_GUIDE.md) for details.\n\n```python\nimport numpy as np\nimport pandas as pd\nfrom sklearn.preprocessing import MinMaxScaler\nfrom tensorflow.keras.models import load_model\n\n# Load training data to fit the scaler\ndf = pd.read_csv('data/body_fat.csv')\nX = df.drop('BodyFat', axis=1)\n\nscaler = MinMaxScaler()\nscaler.fit(X)\n\n# Load pre-trained model\nmodel = load_model('models/best_full_model.keras')\n\n# Predict with scaled input\nmeasurements = np.array([[1.055, 44, 81.1, 178.2, 38.0, 100.8, 92.6, 99.9, 59.4, 38.6, 23.1, 32.3, 28.5, 18.0]])\nscaled = scaler.transform(measurements)\nprediction = model.predict(scaled, verbose=0)\nprint(f\"Predicted body fat: {prediction[0][0]:.2f}%\")\n```\n\n### Custom Model Training\n\n```python\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import MinMaxScaler\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense\n\n# Load and prepare data\ndf = pd.read_csv('data/body_fat.csv')\nX = df.drop('BodyFat', axis=1)\ny = df['BodyFat']\n\n# Scale features and split data\nscaler = MinMaxScaler()\nX_scaled = scaler.fit_transform(X)\nX_train, X_test, y_train, y_test = train_test_split(X_scaled, y, test_size=0.2, random_state=42)\n\n# Create and train model\nmodel = Sequential([\n    Dense(20, activation='sigmoid', input_shape=(X_train.shape[1],)),\n    Dense(1, activation='linear')\n])\n\nmodel.compile(optimizer='adam', loss='mse')\nmodel.fit(X_train, y_train, epochs=1000, batch_size=32, validation_split=0.2)\n\n# Evaluate\ntest_loss = model.evaluate(X_test, y_test)\nprint(f\"Test MSE: {test_loss:.4f}\")\n```\n\n## Research Methodology\n\nThis project follows a seven-phase analysis pipeline:\n\n1. **Qualitative Analysis** — Visual exploration of feature relationships\n2. **Network Optimization** — Hyperparameter tuning and architecture selection\n3. **Correlation Analysis** — Statistical significance testing of feature relationships\n4. **Feature Selection** — Dimensionality reduction while maintaining accuracy\n5. **Sensitivity Analysis** — Feature importance quantification\n6. **Performance Comparison** — Cross-model validation and evaluation\n7. **Clinical Implications** — Real-world applicability assessment\n\n### Correlation Findings\n\n**Strong Predictors (|r| \u003e 0.6):**\n- Body Density: r = -0.99 (physiological gold standard)\n- Abdomen circumference: r = 0.81 (central adiposity)\n- Chest circumference: r = 0.70 (upper body composition)\n- Hip circumference: r = 0.63 (lower body fat distribution)\n\n**Selected Features for Optimized Model:**\nDensity, Abdomen, Chest, Hip, Weight, Thigh, Knee, Biceps, Neck\n\n**Excluded Features (weak correlation):**\nHeight (r = -0.09), Ankle (r = 0.27), Age (r = 0.29), Wrist (r = 0.35), Forearm (r = 0.36)\n\n## Dataset\n\n- **Source**: 252 anthropometric measurements\n- **Features**: 14 body measurements (Density, Age, Weight, Height, Neck, Chest, Abdomen, Hip, Thigh, Knee, Ankle, Biceps, Forearm, Wrist)\n- **Target**: Body fat percentage\n- **Location**: `data/body_fat.csv`\n\n## Project Structure\n\n```\nbodyfat-estimation-mlp/\n├── data/\n│   └── body_fat.csv                        # Anthropometric dataset (252 samples)\n├── models/\n│   ├── best_full_model.keras               # Full model (20 neurons, 14 features)\n│   └── best_selected_features_model.keras  # Optimized model (5 neurons, 9 features)\n├── notebooks/\n│   ├── 01_qualitative_analysis.ipynb       # Visual feature exploration\n│   ├── 02_network_performance.ipynb        # Network optimization\n│   ├── 03_correlation_analysis.ipynb       # Statistical correlation testing\n│   ├── 04_reduced_input_model.ipynb        # Feature selection \u0026 reduced model\n│   ├── 05_sensitivity_analysis.ipynb       # Feature importance analysis\n│   ├── 06_performance_comparison.ipynb     # Model comparison \u0026 evaluation\n│   └── 07_summary_and_conclusions.ipynb    # Summary \u0026 clinical implications\n├── figures/\n│   ├── correlation_heatmap.png             # Feature correlation matrix\n│   └── correlation_with_bodyfat.png        # Body fat correlation chart\n├── requirements.txt                        # Python dependencies\n├── MODEL_USAGE_GUIDE.md                    # Pre-trained model usage guide\n├── CODE_OF_CONDUCT.md                      # Community guidelines\n├── LICENSE                                 # MIT License\n└── README.md\n```\n\n## Contributing\n\nContributions are welcome! Areas of interest:\n\n- Model architecture improvements and alternative algorithms\n- Cross-population validation studies\n- Additional feature engineering approaches\n- Documentation and tutorial improvements\n\n**Process:**\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/your-feature`)\n3. Commit your changes (`git commit -m 'feat: add your feature'`)\n4. Push to the branch (`git push origin feature/your-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.\n\n## Author\n\n**Chan Meng**\n\n[![LinkedIn](https://img.shields.io/badge/LinkedIn-chanmeng666-0A66C2?style=flat-square\u0026logo=linkedin)](https://www.linkedin.com/in/chanmeng666/)\n[![GitHub](https://img.shields.io/badge/GitHub-ChanMeng666-181717?style=flat-square\u0026logo=github)](https://github.com/ChanMeng666)\n[![Email](https://img.shields.io/badge/Email-chanmeng.dev-EA4335?style=flat-square\u0026logo=gmail)](mailto:chanmeng.dev@gmail.com)\n[![Website](https://img.shields.io/badge/Website-chanmeng.org-0078D4?style=flat-square\u0026logo=safari)](https://chanmeng.org/)\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanmeng666%2Fbodyfat-estimation-mlp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanmeng666%2Fbodyfat-estimation-mlp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanmeng666%2Fbodyfat-estimation-mlp/lists"}