An end-to-end Machine Learning data preparation framework transforming raw multi-feature physical performance records into clean, engineered, and scaled model-ready datasets.
- 1. Project Overview & Abstract
- 2. Data Pipeline Architecture
- 3. 14-Step Physiological Data Cleaning Audit
- 4. Exploratory Data Analysis & Key Insights
- 5. Feature Engineering & Mathematical Specifications
- 6. Data Transformations (Encoding & Scaling)
- 7. Machine Learning Model Readiness
- 8. Repository Directory Structure
- 9. Installation & Quick Start Guide
- 10. Author & Acknowledgments
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).
-
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
classis perfectly balanced (~25% in each tier A–D), eliminating majority-class bias. Dual scaled exports (StandardScalerandMinMaxScaler) enable immediate consumption by distance-based, linear, and neural network algorithms.
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ 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) │
└────────────────────────────────────────────────────────────────────────────────────────┘
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 |
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)
-
⚖️ Perfect Target Balance:
The target variableclasscontains an equal distribution across all 4 performance tiers ($\approx 25%$ per class), ensuring machine learning classifiers will not suffer from class imbalance bias. -
🏋️ Dynamic Strength & Power as Top Discriminators:
sit-ups countsandbroad jump_cmexhibit strong monotonic alignment with performance tiers. Participants in Class A average$> 53$ sit-ups and$> 225$ cm broad jump distances, whereas Class D averages$< 31$ sit-ups. -
🚺🚹 Gender Dimorphism & Relative Strength Normalization:
Male participants display higher absolutegripForce($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. -
🧘 Non-Linear Flexibility Threshold:
sit and bend forward_cmserves as a strict boundary metric. Negative flexibility scores ($< 0$ cm) are overwhelmingly concentrated in Class C and Class D, indicating posterior chain tightness. -
🫀 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. -
🎯 Label Contradiction Resolution:
Step 14 detected participant records scoring$> 70$ sit-ups assigned to Class D (worst tier). Eliminating label corruption prevents neural networks and decision trees from learning conflicting split boundaries. -
📊 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.
We derive 7 domain-specific features grounded in exercise physiology and cardiovascular metrics:
| Feature Name | Derived Formula | Data Type | Physiological Concept |
|---|---|---|---|
BMI |
float64 |
Overall body mass index relative to height. | |
fat_mass_kg |
float64 |
Total body fat mass in kilograms. | |
lean_mass_kg |
float64 |
Fat-free muscle and skeletal tissue mass. | |
MAP |
float64 |
Mean Arterial Pressure (average organ perfusion pressure). | |
pulse_pressure |
float64 |
Vascular stiffness and cardiac stroke effort indicator. | |
relative_grip |
float64 |
Bodyweight-normalized upper body strength. | |
power_index |
float64 |
Combined muscular endurance and lower-body explosive power. |
-
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$ ).
We scale numerical predictor features using two complementary transformations:
-
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. -
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.
| 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 ( |
Random Forest, XGBoost, LightGBM, Decision Trees |
| Preprocessed Scaled | data_preprocessed.csv |
13,278 | 19 | StandardScaler ( |
class ( |
SVM, Logistic Regression, Neural Networks, KNN |
.
├── 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
git clone https://github.com/KarimMostafa/Body-Performance-Analytics.git
cd Body-Performance-Analytics# Windows (PowerShell / CMD)
python -m venv venv
.\venv\Scripts\activate
# macOS / Linux
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtjupyter notebook 01_EDA_and_Preprocessing_Pipeline.ipynbData Analyst & Machine Learning Engineer
Primary Tech Stack & Tools:
Python • Pandas • NumPy • Matplotlib • Seaborn • Scikit-Learn • Jupyter • LaTeX
This project is licensed under the MIT License.
Built with ❤️ by Karim Mostafa — 2026
