Skip to content

Mher-1902/Kaggle-Introvert-vs-Extrovert

Repository files navigation

Introvert vs Extrovert — Kaggle Personality Classification

Python Task Imbalance License

End‑to‑end pipeline for the Kaggle Introvert vs Extrovert challenge.
Target: Personality (1 = Extrovert, 0 = Introvert).

Leaderboard (Final):

  • Public: 0.973279
  • Private: 0.970040

📁 Repository Layout (current)

.
├── df_model_ready_top20.csv          # Train-ready feature table (top-20 features + label)
├── df_test_ready_top20.csv           # Test-ready feature table (top-20 features)
├── eda.ipynb                         # Full EDA & feature engineering
├── eda_test.ipynb                    # EDA & checks on test set
├── models (1).ipynb                  # Training (SMOTE, LR/NB/SVM/AdaBoost/XGBoost), thresholds, submissions
├── train.csv                         # Kaggle train (raw)
└── test.csv                          # Kaggle test (raw)

If you use a different structure later (e.g., src/), adjust commands below accordingly.


🧠 Feature Engineering (highlights)

  • Base rename: Time_spent_Alone→alone, Social_event_attendance→events, Going_outside→outside, Friends_circle_size→friends, Post_frequency→posts
  • Ratios & interactions: social_activity_index, extroversion_strength, social_vs_alone_ratio, alone_per_post, events_per_outside, friends_posts_interaction, etc.
  • Binning: _bin4 per core numeric feature
  • Skew fix: Yeo–Johnson on Time_spent_Alone
  • Scaling: StandardScaler on numeric block
  • Missing data: mode for binaries; KNNImputer (k=5) for behavior counts; MICE/IterativeImputer for Time_spent_Alone

🔁 Modeling Pipeline (what the notebooks run)

  1. Split: stratified train/valid (80/20, random_state=42)
  2. Imbalance: SMOTE (train only, no leakage)
  3. Baselines: GaussianNB, Logistic Regression (ridge tuned), SVM (RBF grid), AdaBoost (stumps/depth=2)
  4. XGBoost: random search (global → local), 5‑fold CV AUC, early stopping; small seed‑ensemble
  5. Thresholding: Youden‑J & best‑F1; report ROC‑AUC, F1, confusion matrix
  6. Submission: export predictions (final_predictions_xgboost.csv, final_predictions_logreg.csv)

🚀 Quickstart

# 1) Environment
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
python -m pip install -U pip
pip install -r requirements.txt

# 2) Put Kaggle CSVs (if not already here)
# train.csv, test.csv at repo root

# 3) Run notebooks (recommended)
# - eda.ipynb       → data checks + feature engineering ideas
# - models (1).ipynb → SMOTE + models + XGBoost + submissions
# - eda_test.ipynb   → sanity checks for test

# 4) Ready-made tables (optional)
# If you already have these produced, you can skip straight to modeling:
#   - df_model_ready_top20.csv
#   - df_test_ready_top20.csv

Tip: If you convert the training cells into a script later (e.g., train_infer.py), add a CLI block and document it here.


📊 Validation & Leaderboard

  • Metrics tracked: ROC‑AUC (primary), F1, Precision/Recall, Accuracy, Balanced Accuracy, MCC
  • Threshold picked via Youden‑J or Best‑F1 depending on objective
  • Final Kaggle: Public 0.973279, Private 0.970040

Artifacts:

  • final_predictions_xgboost.csv
  • final_predictions_logreg.csv

⚖️ Notes on Imbalance

  • Class distribution is skewed toward Extrovert (1).
  • We apply SMOTE to training only; validation remains untouched to reflect real distribution.

🧪 Reproducibility

  • Global random_state = 42 where applicable
  • Seed‑ensemble for XGBoost: [7, 17, 29, 42, 73]
  • Minor nondeterminism can arise from BLAS/threads; best submissions are versioned in /

📦 Requirements

See requirements.txt for the exact list:

  • pandas, numpy, scikit‑learn, imbalanced‑learn, xgboost
  • matplotlib, seaborn, scipy, statsmodels, joblib

📝 License

MIT (see LICENSE)


🙌 Acknowledgements

  • Kaggle Introvert vs Extrovert dataset & community.
  • Thanks to reviewers and discussion threads that inspired additional feature ideas.

About

Kaggle Introvert vs Extrovert — Personality classification with strong leaderboard score (0.973/0.970).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors