An end-to-end Machine Learning pipeline and empirical study predicting human personality types (Extrovert, Introvert, Ambivert) from behavioral and psychological traits.
This repository features pure-Python and NumPy implementations from first mathematical principles of Decision Trees, Random Forests, and AdaBoost, benchmarked against industry standards on a 20,000-sample dataset.
Personality-Prediction-ML/
├── data/
│ └── Data.csv # Personality traits dataset (20,000 records, 30 features)
├── src/ # Core mathematical models from scratch
│ ├── __init__.py # Package interface
│ ├── decision_tree.py # Custom Decision Tree (Gini Impurity & Information Gain)
│ ├── random_forest.py # Custom Random Forest (Bagging & Subsampling)
│ └── ada_boost.py # Custom AdaBoost (Multi-Class SAMME Boosting)
├── notebooks/
│ └── personality_prediction.ipynb # Interactive analysis, EDA, tuning & visual metrics
├── demo.py # Standalone benchmark runner comparing vs Scikit-Learn
├── requirements.txt # Dependency list
├── .gitignore # Git ignore exclusions
└── README.md # Documentation
-
Pure First-Principles Implementation (
src/):- Decision Tree Classifier: Built with recursive binary partitioning, customizable maximum depth, minimum sample leaf size, and exact Gini impurity minimization.
-
Random Forest Classifier: Features Bootstrap Aggregation (Bagging) and Random Feature Subsampling (
$\sqrt{p}$ ) for variance reduction. - AdaBoost Classifier: Implements multi-class adaptive boosting with decision stumps, dynamic sample weighting, and SAMME estimator weighting.
-
Real-World Case Study (
data/Data.csv): Predicts personality categories across 30 behavioral indicators including social energy, alone time preference, decision speed, and stress handling. -
Exploratory Data Analysis & Notebook (
notebooks/): Full data distribution analysis, feature correlations, and validation curves. -
Benchmarking CLI (
demo.py): Instant side-by-side accuracy and execution-time comparison between custom models andscikit-learn.
For dataset
The optimal split maximizes Information Gain:
For
git clone https://github.com/itsIbrahim03/Personality-Prediction-ML.git
cd Personality-Prediction-ML
pip install -r requirements.txtpython demo.pyjupyter notebook notebooks/personality_prediction.ipynb| Model Architecture | Custom From-Scratch Accuracy | Scikit-Learn Accuracy | Performance Parity |
|---|---|---|---|
| Decision Tree (depth=5) | ~89.2% | ~90.3% | 98.8% Match |
| Random Forest (15 trees) | ~98.0% | ~98.7% | 99.3% Match |
| AdaBoost (15 stumps) | ~90.7% | ~85.5% | Outperformed Sklearn |