Building Features
Thebuild_features() function creates three new features from the cleaned dataset.
Function Signature
df(pd.DataFrame): Cleaned hospital data from the preprocessing pipeline
- DataFrame with original columns plus new engineered features
Engineered Features
1. Age Range
Categorizes patients into age groups usingpd.cut():
0-15- Children and adolescents15-35- Young adults35-55- Middle-aged adults55-70- Older adults70-80- Senior adults
right=False- Left-inclusive bins (e.g., 15 ≤ age < 35)
2. Adult Indicator
Binary flag indicating whether the patient is an adult (≥18 years):1- Adult (age ≥ 18)0- Minor (age < 18)
3. BMI Risk Category
Categorizes Body Mass Index into risk levels based on standard health guidelines:0- Underweight (BMI < 18.5) or missing1- Normal weight (18.5 ≤ BMI < 25)2- Overweight (25 ≤ BMI < 30)3- Obese (BMI ≥ 30)
| BMI Range | Risk Level | Category |
|---|---|---|
| < 18.5 | 0 | Underweight |
| 18.5 - 24.9 | 1 | Normal |
| 25 - 29.9 | 2 | Overweight |
| ≥ 30 | 3 | Obese |