Skip to content

Repository files navigation

Project Banner

📊 Body Performance Analytics

Production-Grade Data Cleaning, Exploratory Analysis, & ML Pipeline

Python 3.10+ Pandas 2.0+ Scikit-Learn 1.2+ Jupyter License: MIT Status: Production-Ready

An end-to-end Machine Learning data preparation framework transforming raw multi-feature physical performance records into clean, engineered, and scaled model-ready datasets.


📌 Table of Contents


1. Project Overview & Abstract

Predictive performance tier classification (Class A: Elite, Class B: Good, Class C: Average, Class D: Below Average) plays a central role in sports science, military readiness evaluation, and public health risk modeling. However, physical test measurements collected under field conditions frequently suffer from human data-entry typos, sensor zeroing errors, physiological impossibilities, and non-linear feature interactions.

This repository provides a production-ready Data Science & Machine Learning Preprocessing Pipeline engineered on the Body Performance Dataset (13,393 participant records across 12 physical and physiological features).

🌟 Key Engineering Highlights:

  • Domain-Informed Cleaning over Naive Trimming: Standard $1.5 \times \text{IQR}$ statistical truncation aggressively discards top-tier athletic outliers. Instead, we implement a 14-step sequential rule system based on physiological limits, eliminating corrupt records while preserving genuine performance signals.
  • 7 Derived Physiological Features: Engineered domain metrics including Body Mass Index (BMI), Fat/Lean Body Mass, Mean Arterial Pressure (MAP), Pulse Pressure, Relative Grip Strength, and Power Index.
  • Multiclass Balance & Model Readiness: Target class is perfectly balanced (~25% in each tier A–D), eliminating majority-class bias. Dual scaled exports (StandardScaler and MinMaxScaler) enable immediate consumption by distance-based, linear, and neural network algorithms.

2. Data Pipeline Architecture

┌────────────────────────────────────────────────────────────────────────────────────────┐
│                                1. DATA INGESTION & AUDIT                               │
│  - Input: raw `bodyPerformance.csv` (13,393 rows x 12 features)                        │
│  - Check schema, data types, missing values (0 missing), & duplicates (1 duplicate)    │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│                     2. SEQUENTIAL PHYSIOLOGICAL CLEANING (14 RULES)                    │
│  - Step 01–05 : Blood pressure logic errors (diastolic >= systolic, 0s, hypertensive) │
│  - Step 06–08 : Anthropometric boundaries (height < 140cm, weight < 30kg, fat > 60%)  │
│  - Step 09–12 : Flexibility & BMI anomalies (sit-and-reach < -15cm, BMI < 17)        │
│  - Step 13–14 : Broad jump clipping (< 25cm) & Sit-ups contradiction (Class D error)   │
│  - Output: 13,278 clean rows (115 anomalous rows removed = 0.86% data loss)            │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│                        3. EXPLORATORY DATA ANALYSIS (EDA)                              │
│  - Density distribution overlay validation (Raw vs. Cleaned distributions)             │
│  - Target tier balance audit & bivariate class boxplots                                │
│  - Gender dimorphism split violin plots & Pearson correlation heatmap                  │
│  - 5-Feature pairplot separation matrix                                                │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│                           4. PHYSIOLOGICAL FEATURE ENGINEERING                         │
│  - Anthropometric: BMI, Fat Mass (kg), Lean Mass (kg)                                  │
│  - Cardiovascular: Mean Arterial Pressure (MAP), Pulse Pressure                        │
│  - Performance: Relative Grip Strength (Grip / Weight), Power Index (Sit-ups x Jump)   │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│                        5. CATEGORICAL ENCODING & FEATURE SCALING                       │
│  - Binary Encoding : `gender` (Male = 1, Female = 0)                                   │
│  - Ordinal Encoding: `class`  (A = 3, B = 2, C = 1, D = 0)                              │
│  - Scaling Options : StandardScaler (Z-score) & MinMaxScaler (0-1)                     │
└───────────────────────────────────────────┬────────────────────────────────────────────┘
                                            │
                                            ▼
┌────────────────────────────────────────────────────────────────────────────────────────┐
│                            6. PRODUCTION CSV EXPORTS                                   │
│  - Output 1: `data_clean.csv`        (13,278 rows x 20 columns - Unscaled)            │
│  - Output 2: `data_preprocessed.csv` (13,278 rows x 19 columns - StandardScaled)      │
└────────────────────────────────────────────────────────────────────────────────────────┘

3. 14-Step Physiological Data Cleaning Audit

Note

Sequential execution is critical: subsequent rules (e.g., BMI calculation) depend on prior rules (height/weight validation) already being clean, preventing double-counting of overlapping anomalies.

Step Target Feature Rule Condition Action Taken Physiological Rationale Impact / Count
01 diastolic, systolic diastolic >= systolic Drop Row Diastolic pressure must strictly be lower than systolic pressure. 16 rows dropped
02 systolic systolic == 0 Drop Row Zero blood pressure reading represents sensor zeroing / missing error. 1 row dropped
03 diastolic diastolic == 0 Drop Row Zero blood pressure reading represents sensor zeroing / missing error. 1 row dropped
04 systolic systolic > 190 mmHg Drop Row Medically extreme resting hypertension; unfit for performance testing. 3 rows dropped
05 diastolic diastolic > 120 mmHg Drop Row Hypertensive crisis territory; unfit for performance testing. 1 row dropped
06 body fat_% body fat_% > 60% Drop Row Body fat percentage above 60% is a clear data entry error for active subjects. 1 row dropped
07 height_cm height_cm < 140 cm Drop Row Impossible adult height (population age range 21–64 years). 1 row dropped
08 weight_kg weight_kg < 30 kg Drop Row Impossible adult body mass for tested age demographic. 1 row dropped
09 sit and bend forward_cm flexibility > 45 cm Drop Row Exceeds anatomical limit of sit-and-reach flexibility box. 1 row dropped
10 sit and bend forward_cm flexibility < -15 cm Drop Row Extreme negative scores represent severe tightness/injury or test error. 84 rows dropped
11 BMI_raw BMI < 17 Drop Row Severe underweight beyond adult physiological safety margins. 4 rows dropped
12 height_cm, weight_kg, age Height $>165$cm & Weight $<40$kg & Age $&gt;20$ Drop Row Cross-feature thinness sanity check secondary safety net. 0 rows dropped
13 broad jump_cm broad jump_cm < 25 cm Clip (25) Jump recording typo; clipping preserves row signal without data loss. 10 rows clipped
14 sit-ups counts, class sit-ups > 70 & class == 'D' Drop Row Logical contradiction: elite sit-up score assigned to worst class tier D. 1 row dropped

Cleaning Audit Summary:

  • Initial Row Count: $13,393$
  • Total Removed Rows: $115$
  • Final Clean Row Count: $13,278$ ($99.14%$ retention, $0.86%$ data loss)

4. Exploratory Data Analysis & Key Insights

🎯 Top 7 Actionable Business & Physiological Findings

  1. ⚖️ Perfect Target Balance:
    The target variable class contains an equal distribution across all 4 performance tiers ($\approx 25%$ per class), ensuring machine learning classifiers will not suffer from class imbalance bias.

  2. 🏋️ Dynamic Strength & Power as Top Discriminators:
    sit-ups counts and broad jump_cm exhibit strong monotonic alignment with performance tiers. Participants in Class A average $&gt; 53$ sit-ups and $&gt; 225$ cm broad jump distances, whereas Class D averages $&lt; 31$ sit-ups.

  3. 🚺🚹 Gender Dimorphism & Relative Strength Normalization:
    Male participants display higher absolute gripForce ($46.8$ kg vs. $28.3$ kg) and broad jump distance. However, normalizing grip force by body weight (relative_grip = $\text{Grip} / \text{Weight}$) aligns relative athletic performance across genders.

  4. 🧘 Non-Linear Flexibility Threshold:
    sit and bend forward_cm serves as a strict boundary metric. Negative flexibility scores ($&lt; 0$ cm) are overwhelmingly concentrated in Class C and Class D, indicating posterior chain tightness.

  5. 🫀 Cardiovascular Risk Stratification:
    Systolic and diastolic blood pressure show strong linear correlation ($r = 0.68$). Deriving Mean Arterial Pressure (MAP) ($\text{Diastolic} + \frac{1}{3}\Delta\text{BP}$) condenses blood pressure into a unified cardiovascular load index.

  6. 🎯 Label Contradiction Resolution:
    Step 14 detected participant records scoring $&gt; 70$ sit-ups assigned to Class D (worst tier). Eliminating label corruption prevents neural networks and decision trees from learning conflicting split boundaries.

  7. 📊 Zero-Distortion Data Integrity:
    Overlaid density histograms confirm that the 14-step cleaning pipeline eliminated corrupt records while preserving the underlying continuous distributions of all valid features.


5. Feature Engineering & Mathematical Specifications

We derive 7 domain-specific features grounded in exercise physiology and cardiovascular metrics:

$$\text{BMI} = \frac{\text{Weight (kg)}}{\left(\frac{\text{Height (cm)}}{100}\right)^2}$$ $$\text{Fat Mass (kg)} = \text{Weight (kg)} \times \left(\frac{\text{Body Fat \%}}{100}\right)$$ $$\text{Lean Mass (kg)} = \text{Weight (kg)} - \text{Fat Mass (kg)}$$ $$\text{MAP (mmHg)} = \text{Diastolic} + \frac{1}{3} \times \left(\text{Systolic} - \text{Diastolic}\right)$$ $$\text{Pulse Pressure (mmHg)} = \text{Systolic} - \text{Diastolic}$$ $$\text{Relative Grip} = \frac{\text{Grip Force (kg)}}{\text{Weight (kg)}}$$ $$\text{Power Index} = \text{Sit-ups Count} \times \text{Broad Jump (cm)}$$

📋 Engineered Feature Definitions & Data Types

Feature Name Derived Formula Data Type Physiological Concept
BMI $\text{Weight} / \text{Height}^2$ float64 Overall body mass index relative to height.
fat_mass_kg $\text{Weight} \times (\text{Body Fat %} / 100)$ float64 Total body fat mass in kilograms.
lean_mass_kg $\text{Weight} - \text{Fat Mass}$ float64 Fat-free muscle and skeletal tissue mass.
MAP $\text{Diastolic} + \frac{1}{3}(\text{Systolic} - \text{Diastolic})$ float64 Mean Arterial Pressure (average organ perfusion pressure).
pulse_pressure $\text{Systolic} - \text{Diastolic}$ float64 Vascular stiffness and cardiac stroke effort indicator.
relative_grip $\text{Grip Force} / \text{Weight}$ float64 Bodyweight-normalized upper body strength.
power_index $\text{Sit-ups Count} \times \text{Broad Jump}$ float64 Combined muscular endurance and lower-body explosive power.

6. Data Transformations (Encoding & Scaling)

🔤 Categorical & Target Encoding

  • Gender (gender): Binary Mapping ($\text{Male} \rightarrow 1$, $\text{Female} \rightarrow 0$).
  • Performance Class (class): Ordinal Mapping ($\text{Class A} \rightarrow 3$, $\text{Class B} \rightarrow 2$, $\text{Class C} \rightarrow 1$, $\text{Class D} \rightarrow 0$).

🔢 Numerical Feature Scaling

We scale numerical predictor features using two complementary transformations:

  1. StandardScaler (Z-Score Standardization): $$\mu = 0, \quad \sigma = 1 \quad \implies \quad z = \frac{x - \mu}{\sigma}$$ Recommended for: Logistic Regression, Support Vector Machines (SVM), K-Nearest Neighbors (KNN), and Neural Networks.

  2. MinMaxScaler (0–1 Normalization): $$x_{\text{scaled}} = \frac{x - x_{\min}}{x_{\max} - x_{\min}}$$ Recommended for: Neural Networks with bounded activation functions, Distance Metrics, and Gradient-based Optimizers.


7. Machine Learning Model Readiness

Dataset Export File Name Rows Columns Scaling Transformation Target Column Primary Model Use-Case
Clean Unscaled data_clean.csv 13,278 20 Unscaled (Raw Units) class ($3, 2, 1, 0$) Random Forest, XGBoost, LightGBM, Decision Trees
Preprocessed Scaled data_preprocessed.csv 13,278 19 StandardScaler ($z$-score) class ($3, 2, 1, 0$) SVM, Logistic Regression, Neural Networks, KNN

8. Repository Directory Structure

.
├── 01_EDA_and_Preprocessing_Pipeline.ipynb   # Production Jupyter Notebook (Main Execution Pipeline)
├── README.md                                 # Recruiter-Ready GitHub Documentation
├── requirements.txt                          # Production Python Dependency List
├── bodyPerformance.csv                        # Raw Dataset (13,393 rows x 12 columns)
├── data_clean.csv                             # Cleaned Dataset with 7 Engineered Features (Unscaled)
├── data_preprocessed.csv                      # Fully Preprocessed & StandardScaled Dataset
├── images/
│   └── hayper_digi_dashboard.png              # Project Header Banner Image
├── assets/
│   └── banner.png                            # Backup High-Resolution Banner Image
└── 01,02. EDA (Data Analysis and Preprocessing)/
    ├── 01. EDA/
    │   └── Final/
    │       ├── 01_EDA _new.ipynb             # Exploratory Analysis Working Notebook
    │       └── 02_Preprocessing_(1).ipynb    # Preprocessing Rules Prototype Notebook
    └── Data/
        ├── bodyPerformance-original data.csv  # Original Source CSV Copy
        └── Data Cleaned.csv                   # Legacy Clean Dataset Copy

9. Installation & Quick Start Guide

1. Clone the Repository

git clone https://github.com/KarimMostafa/Body-Performance-Analytics.git
cd Body-Performance-Analytics

2. Create & Activate Virtual Environment

# Windows (PowerShell / CMD)
python -m venv venv
.\venv\Scripts\activate

# macOS / Linux
python3 -m venv venv
source venv/bin/activate

3. Install Required Dependencies

pip install -r requirements.txt

4. Run the Jupyter Notebook

jupyter notebook 01_EDA_and_Preprocessing_Pipeline.ipynb

10. Author & Acknowledgments

👨‍💻 Karim Mostafa

Data Analyst & Machine Learning Engineer

LinkedIn

Primary Tech Stack & Tools:
PythonPandasNumPyMatplotlibSeabornScikit-LearnJupyterLaTeX


This project is licensed under the MIT License.

Built with ❤️ by Karim Mostafa — 2026

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages