HR analytics project analyzing employee attrition using machine learning
Employee attrition is a critical challenge for organizations, directly impacting productivity, operational costs, and long-term growth. This project focuses on analyzing employee data to understand the key factors that contribute to attrition and to model the probability that an employee will leave the company.
Using an HR Analytics dataset from Kaggle, this case study applies data analysis and machine learning techniques to identify patterns in employee behavior and generate insights that support data-driven human resource decision-making.
- Identify the main factors associated with employee attrition
- Explore relationships between employee satisfaction, workload, performance, and tenure
- Build a predictive model to estimate the probability of employee attrition
- Communicate findings in a clear and actionable way for stakeholders
| Milestone | Description |
|---|---|
| 1 | Problem Identification |
| 2 | Data Collection |
| 3 | Exploratory Data Analysis |
| 4 | Communicating Results |
Employee turnover creates financial and operational challenges for organizations. Understanding why employees leave and identifying early warning signals is essential for improving retention strategies.
This project aims to model employee attrition and determine which factors most strongly influence an employee’s decision to leave the company.
- What factors most strongly influence employee attrition, and how accurately can attrition be predicted using employee data?
- How does employee satisfaction relate to attrition?
- Does workload (number of projects and monthly working hours) affect employee retention?
- What role do promotions, salary level, and department play in employee attrition?
- How does time spent in the company influence the likelihood of leaving?
The dataset used in this project is the HR Analytics Dataset available on Kaggle.
It contains employee-level information related to satisfaction, performance, workload, tenure, and compensation.
- Rows: 14,999 employees
- Columns: 10 features
- Missing Values: None
Each row represents a single employee, and the target variable indicates whether the employee has left the company.
The first stage of the analysis focuses on understanding the dataset structure, interpreting variables, identifying patterns, and preparing the data for machine learning.
| Variable | Type | Range | Description |
|---|---|---|---|
| satisfaction_level | Float | 0–1 | Employee satisfaction level |
| last_evaluation | Float | 0–1 | Last evaluation score |
| number_project | Integer | 2–7 | Number of projects handled |
| average_monthly_hours | Integer | 96–310 | Average monthly working hours |
| time_spend_company | Integer | 2–10 | Years spent at the company |
| Work_accident | Boolean | 0 or 1 | Whether the employee had a work accident |
| Left | Boolean | 0 or 1 | Whether the employee left the company (target variable) |
| promotion_last_5years | Boolean | 0 or 1 | Promotion in the last 5 years |
| department | Categorical | 10 values | Employee department |
| salary | Categorical | 3 values | Salary level: Low, Medium, High |
During EDA, the dataset is examined to:
- Understand variable distributions
- Detect correlations between features and attrition
- Identify potential patterns linked to employee turnover
- Prepare the data for modeling
The following Python libraries are used throughout the project:
- pandas – data manipulation and analysis
- numpy – numerical computing
- matplotlib.pyplot – data visualization
- seaborn – statistical data visualization
- scikit-learn – preprocessing and machine learning models
The analysis uses Logistic Regression as the primary machine learning model to predict employee attrition. This model serves as a strong and interpretable baseline for understanding the key factors influencing employee turnover and for estimating the probability that an employee will leave the organization. Its interpretability makes it especially suitable for HR analytics, where insights must be clearly communicated to management and stakeholders.