End-to-end machine-learning pipeline.
Using the 1994 UCI Adult (βCensus Incomeβ) data, we predict whether an individual earns > $50 K / year and compare four classical & ensemble algorithms.
| Item | Value |
|---|---|
| File | data/censusData.csv |
| Source | UCI Machine-Learning Repository βΈ Adult (slightly cleaned for education) |
| Size | 32 561 rows Γ 15 raw features |
| Aspect | Details |
|---|---|
| Learning type | Supervised |
| Task | Binary classification |
| Target | income_binary β 0 = β€ $50 K, 1 = > $50 K |
| Feature groups | β’ Continuous (6) age, fnlwgt, education-num, capital-gain, capital-loss, hours-per-week β’ Categorical (9) workclass, education, marital-status, occupation, relationship, race, sex, native-country, income |
-
Data Pre-processing
- Drop rows with placeholder β?β entries.
- Label-encode target; one-hot encode all categorical predictors.
- Standardize continuous variables with
StandardScaler.
-
Feature Selection
- Use SelectKBest with mutual-information scores to keep the top 20 most informative features.
-
Model Training
Model Library / API Key Hyper-params Logistic Regression sklearn.linear_model.LogisticRegressionsolver='lbfgs', max_iter=1000Random Forest sklearn.ensemble.RandomForestClassifiern_estimators=300, max_depth=NoneGradient Boosting (GBDT) sklearn.ensemble.GradientBoostingClassifiern_estimators=400, learning_rate=0.05Stacking Ensemble sklearn.ensemble.StackingClassifierBase: LR + RF + GBDT β Meta: LR -
Evaluation
- Confusion matrices, accuracy, precision-recall curves, and ROC-AUC.
- Training-vs-validation learning curves to spot over/under-fitting.
- Basic fairness probe: check error rates across
sex&race.
| Model | Accuracy (%) | Notes |
|---|---|---|
| Logistic Regression | 84.5 | Fast & highly interpretable |
| Random Forest | 86.3 | Captures non-linear splits; small memory cost |
| Gradient Boosting | 87.3 | Best single model; slower to train |
| Stacking Ensemble | 87.4 | Marginal lift above GBDT |
(Accuracies computed on held-out test set of 6 513 records.)
Preliminary disparate-impact analysis shows higher false-negative rates for women and certain racial groups. Mitigation strategies (re-sampling, re-weighting, post-processing thresholds) are discussed in notebooks/04_fairness_analysis.ipynb.
- Python 3.11
- pandas, NumPy
- scikit-learn
- Matplotlib, Seaborn