How farhann198/predicting-employee-attrition works
Purpose and Execution
This is a notebook-driven Python machine-learning study for predicting employee attrition from IBM HR Analytics data. Its sole execution entry point is attrition-prediction.ipynb; there is no deployed service, API, package, or application runtime. The notebook consumes WA_Fn-UseC_-HR-Employee-Attrition.csv and installs dependencies from requirement.txt.
Data Boundary
WA_Fn-UseC_-HR-Employee-Attrition.csv is the local source-of-truth dataset: 1,470 employee records with HR, demographic, compensation, satisfaction, and career attributes. The supervised classification target is the Attrition Yes/No field. Data processing and outputs are managed interactively inside attrition-prediction.ipynb, rather than persisted as a reusable feature store or model artifact.
Preparation and Feature Pipeline
The notebook’s first major stage performs cleaning, exploratory analysis, and feature preparation in attrition-prediction.ipynb. It converts categorical variables through label and one-hot encoding, constructs model-ready numerical features, and separates predictors from the attrition target. This is the central transformation boundary between raw HR records and learning inputs.
Training and Imbalance Handling
Prepared data is split into train/test partitions in attrition-prediction.ipynb. Class imbalance is addressed with SMOTE-Tomek from imbalanced-learn, intended to resample the training data before fitting. The workflow compares Logistic Regression, Decision Tree, Random Forest, SVM, KNN, Gradient Boosting, and XGBoost models within the notebook.
Optimization and Model Selection
XGBoost is the reported best model. attrition-prediction.ipynb uses Optuna for Bayesian hyperparameter optimization, described as 100 trials, then evaluates trained candidates using classification metrics including accuracy and ROC-AUC. Model selection remains an interactive notebook result; no serialized trained model or inference interface exists in the repository.
Interpretation and Survival Analysis
The notebook adds two analytical paths after predictive modeling. SHAP explains feature-level influence for attrition predictions, with job satisfaction, income, tenure, overtime, and age identified as major contributors. Lifelines Cox proportional-hazards analysis estimates time-to-attrition and reports concordance performance. Both analyses are downstream of the processed employee data and complement—not replace—the binary classifier.
Runtime and External Dependencies
The required runtime is Python in Jupyter, launched manually. Core external libraries include pandas/NumPy for tabular processing, scikit-learn and XGBoost for models, Optuna for tuning, imbalanced-learn for SMOTE-Tomek, SHAP for explainability, and Lifelines for survival modeling; dependencies are declared in requirement.txt. No cloud infrastructure, database, remote inference endpoint, experiment tracker, container, or UI is currently implemented.
Main entry points: attrition-prediction.ipynb Cleaning & feature preparation · requirement.txt Python dependencies · WA_Fn-UseC_-HR-Employee-Attrition.csv IBM HR employee data
Components 12
Notebook Runtime
Manual Python/Jupyter execution.
- Python dependencies · Notebook libraries are declared here.
requirement.txt - Attrition study notebook · The repository's sole execution entry point.
attrition-prediction.ipynb
Attrition Modeling
- Cleaning & feature preparation · Encodes categorical fields and separates predictors from Attrition.
attrition-prediction.ipynb - Train/test split
attrition-prediction.ipynb - SMOTE-Tomek resampling · Resamples training data before fitting.
attrition-prediction.ipynb - Candidate classifiers · Compares linear, tree, SVM, KNN, boosting, and XGBoost models.
attrition-prediction.ipynb - Optuna tuning · Runs Bayesian optimization for XGBoost.
attrition-prediction.ipynb - Selected XGBoost model · Reported best attrition model; retained interactively only.
attrition-prediction.ipynb - Classification evaluation · Evaluates candidates with accuracy and ROC-AUC.
attrition-prediction.ipynb
Downstream Analysis
- SHAP explanations · Explains feature-level influence on attrition predictions.
attrition-prediction.ipynb - Cox survival analysis · Estimates time-to-attrition and concordance.
attrition-prediction.ipynb
Other components
- IBM HR employee data · Local source of truth; Attrition is the Yes/No target.
WA_Fn-UseC_-HR-Employee-Attrition.csv
Connections 12
- Python dependencies → Attrition study notebook: provides libraries
- IBM HR employee data → Attrition study notebook: loaded by
- Attrition study notebook → Cleaning & feature preparation: executes
- Cleaning & feature preparation → Train/test split: model-ready features
- Train/test split → SMOTE-Tomek resampling: training partition
- SMOTE-Tomek resampling → Candidate classifiers: balanced training data
- Candidate classifiers → Optuna tuning: selects XGBoost for tuning
- Optuna tuning → Selected XGBoost model: best hyperparameters
- Candidate classifiers → Classification evaluation: candidate predictions
- Selected XGBoost model → Classification evaluation: selected-model predictions
- Selected XGBoost model → SHAP explanations: prediction explanations
- Cleaning & feature preparation → Cox survival analysis: processed employee data