Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Personality Prediction & Classification with Custom Ensemble ML

Python 3.8+ NumPy Pandas

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.


📁 Repository Organization

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

🌟 Key Features & Algorithms

  • 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 and scikit-learn.

📐 Mathematical Overview

1. Gini Impurity & Information Gain

For dataset $D$ with class proportions $p_k$: $$Gini(D) = 1 - \sum_{k=1}^{K} p_k^2$$

The optimal split maximizes Information Gain: $$IG(D, f, t) = Gini(D) - \left( \frac{|D_{\text{left}}|}{|D|} Gini(D_{\text{left}}) + \frac{|D_{\text{right}}|}{|D|} Gini(D_{\text{right}}) \right)$$

2. Random Forest Aggregation

For $B$ bootstrap trees, class prediction is obtained via majority voting: $$\hat{y} = \arg\max_{k} \sum_{b=1}^{B} \mathbb{I}(\hat{y}_b(x) = k)$$

3. AdaBoost Weight Updates

$$w_i^{(m+1)} = w_i^{(m)} \exp\left( \alpha_m \cdot \mathbb{I}(y_i \neq h_m(x_i)) \right), \quad \alpha_m = \ln\left(\frac{1 - \epsilon_m}{\epsilon_m}\right) + \ln(K - 1)$$


🚀 Quickstart & Usage

1. Installation

git clone https://github.com/itsIbrahim03/Personality-Prediction-ML.git
cd Personality-Prediction-ML
pip install -r requirements.txt

2. Run the Benchmark Demo

python demo.py

3. Open the Interactive Notebook

jupyter notebook notebooks/personality_prediction.ipynb

📊 Benchmark Results

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

About

End-to-end Machine Learning pipeline predicting personality types from 20,000 behavioral records featuring pure-Python & NumPy first-principles implementations of Decision Trees, Random Forests, and SAMME AdaBoost.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages