Skip to content

elifsenab/hr-analytics-logistic-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 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

⚠️ 6. Risk Analysis (Business Impact)

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

About

Predicting employee attrition using logistic regression

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages