This project explores employee attrition patterns using a mix of PostgreSQL for querying and Python for analysis & visualization.
It is designed as a portfolio project β showing end-to-end data handling, from raw CSV β database β SQL analysis β Python stats β machine learning β reproducible deliverables.
HR-Analytics-SQL-Python/
ββ queries/
β ββ basic_checks.sql
β ββ overall_attrition.sql
β ββ dept_attrition.sql
β ββ salary_analysis.sql
β ββ jobrole_attrition.sql
β ββ tenure_attrition.sql
β ββ overtime_attrition.sql
β ββ age_gender_attrition.sql
β
ββ notebook/
β ββ hr_analysis.ipnyb
β ββ eda_summary.ipnyb
β ββ figures/
β ββunivariate/
β β ββ age_distribution.png
β β ββ attribution_balance.png
β β ββ department_counts.png
β β ββ monthly_income_distribution.png
β β ββ overtime_counts.png
β β
β ββbivariate/
β β ββ attrition_vs_age.png
β β ββ attrition_vs_dept.png
β β ββ attrition_vs_gender.png
β β ββ attrition_vs_jobrole.png
β β ββ attrition_vs_maritalstatus.png
β β ββ attrition_vs_monthlyincome.png
β β ββ attrition_vs_overtime.png
β β ββ attrition_vs_tenure.png
β β
β βββeda_summary/
β ββ age_tenure_analysis.png
β ββ attrition.png
β ββ attrition_gender_maritalstatus.png
β ββ dept_and_jobroles.png
β ββ monthlyincome_vs_attrition.png
β ββ overtime_impact.png
ββ data/
β ββ ibm_hr.csv
β
ββ results/
β ββ overall_attrition.csv
β ββ dept_attrition.csv
β ββ salary_analysis.csv
β ββ jobrole_attrition.csv
β ββ tenure_attrition.csv
β ββ overtime_attrition.csv
β ββ age_gender_attrition.csv
β
ββ LICENSE
ββ requirements.txt
ββ README.md # Project Overview (this file)
- Understand employee attrition drivers using SQL queries
- Perform exploratory data analysis (EDA) with Python
- Run statistical checks (e.g., overtime vs attrition significance)
- Build a basic predictive model (logistic regression)
- Deliver visuals, CSV outputs, and notebooks in a clean repo
- Database: PostgreSQL
- Querying: SQL
- Analysis: Python (Pandas, NumPy, Matplotlib, Seaborn, Statsmodels, Scikit-learn)
- Version Control: Git + GitHub
- Overall attrition: ~16% of employees
- Departmental differences: R&D had higher attrition vs HR & Sales
- Overtime: Employees working overtime are significantly more likely to leave
- Job roles: Sales reps & lab technicians showed higher attrition
- Income effect: Lower monthly income strongly correlates with attrition
- Predictive model: Logistic regression flagged Overtime, MonthlyIncome, JobRole, and Age as the strongest predictors.
- About 1 in 6 employees left the company during the observed period.
- Working overtime is one of the biggest factors linked to leaving.
- Lower salary employees tend to leave more often than higher salary ones.
- Certain job roles and departments (like Sales and Lab Techs) have higher turnover.
- Younger employees are more likely to quit compared to older ones.
- Reproducible SQL queries β
queries/ - Query outputs β
results/ - Python notebooks with EDA, stats, and model β
notebook/ - Figures for visualization β
notebook/figures/ - README.md (project overview)
-
Clone this repo
git clone https://github.com/ajx7/HR-Analytics-SQL-Python.git cd HR-Analytics-SQL-Python -
Install requirements
pip install -r requirements.txt
-
Set up PostgreSQL DB
- Create a database
- Import
data/ibm_hr.csv
-
Run SQL scripts in
queries/ -
Open notebooks in
notebook/for Python analysis
IBM HR Analytics Employee Attrition & Performance dataset (publicly available on Kaggle): IBM HR Analytics Dataset β Kaggle
This project is licensed under the MIT License β free to use with attribution.
This project was built as part of a portfolio refresh, showing end-to-end data analysis and reproducibility skills.