π§ Employee Attrition Analysis & Prediction
π Project Objective This project aims to analyze employee attrition behavior and predict employees who are at risk of leaving the company.
Goals:
Identify key factors influencing employee attrition
Detect high-risk employee groups
Generate data-driven HR (Human Resources) insights
Predict attrition probability using machine learning
π Technologies Used
Python
Pandas / NumPy β Data manipulation and analysis
DuckDB β SQL-based data analysis
Matplotlib β Data visualization
Scikit-learn β Machine learning modeling
π Dataset
The project uses a dataset containing various employee-related features:
Demographic information (Age, MaritalStatus, etc.)
Job-related data (JobRole, Department, BusinessTravel)
Performance & satisfaction metrics (JobSatisfaction, WorkLifeBalance)
Compensation (MonthlyIncome)
Experience (TotalWorkingYears, YearsWithCurrManager)
Target variable: Attrition (Yes / No)
π 1. Exploratory Data Analysis (EDA)
SQL queries (via DuckDB) were used to explore the dataset.
π General Analysis
Average employee age
Employee count by department
Age distribution by education field
π Attrition Analysis
Attrition rate by business travel frequency
Attrition across age groups
Impact of overtime on attrition
Effect of marital status
π Key Insights
Employees working overtime have higher attrition rates
Low work-life balance is strongly associated with attrition
Longer time since last promotion increases attrition risk
Younger employees tend to have higher attrition rates
βοΈ 2. Data Preprocessing
Before modeling, the dataset was prepared as follows:
Converted Attrition to binary format (Yes β 1, No β 0)
Dropped irrelevant columns
Categorical variables:
Transformed using One-Hot Encoding
Data split:
Train/Test split (80% / 20%)
Feature scaling:
Applied StandardScaler
π€ 3. Modeling
Model Used:
Logistic Regression
Model Configuration:
class_weight="balanced" β to handle class imbalance
max_iter=2000
π 4. Model Performance
Evaluation metrics:
Accuracy
ROC AUC Score
Classification Report:
Precision
Recall
F1-score
Additional Visualizations:
Confusion Matrix
ROC Curve
π 5. Feature Importance (Interpretability)
Model coefficients were analyzed to understand feature impact:
πΊ Factors Increasing Attrition Risk:
Overtime
Low job satisfaction
Long time since last promotion
Low income
π» Factors Decreasing Attrition Risk:
High job satisfaction
Higher income
Strong/long-term manager relationships
Using the trained model:
Current employees were evaluated
High-risk individuals (attrition probability > 70%) were identified
This enables:
Proactive HR interventions
Reduction of employee turnover
π‘ Use Case Scenario
HR teams can leverage this model to:
Answer: βWho is likely to leave?β
Design targeted retention strategies
Optimize salary, promotion, and workload policies