Dataset Guide — HR Analytics¶
Source¶
Dataset: IBM HR Analytics Employee Attrition & Performance
URL: https://www.kaggle.com/datasets/pavansubhasht/ibm-hr-analytics-attrition-dataset
File: WA_Fn-UseC_-HR-Employee-Attrition.csv
Size: 1,470 rows × 35 columns
Key Column Descriptions¶
| Column | Type | Description |
|---|---|---|
Attrition |
str | Target: "Yes" (left) or "No" (stayed) |
Age |
int | Employee age |
Department |
str | Sales, R&D, HR |
JobRole |
str | 9 roles (Sales Exec, Research Scientist, etc.) |
JobLevel |
int | 1 (junior) to 5 (senior) |
MonthlyIncome |
int | Monthly salary |
YearsAtCompany |
int | Tenure |
YearsInCurrentRole |
int | Time in current role |
YearsSinceLastPromotion |
int | Time since last promotion |
TotalWorkingYears |
int | Total career experience |
OverTime |
str | "Yes" or "No" |
BusinessTravel |
str | Non-Travel, Travel_Rarely, Travel_Frequently |
DistanceFromHome |
int | Miles from home to office |
JobSatisfaction |
int | 1 (Low) to 4 (Very High) |
EnvironmentSatisfaction |
int | 1 to 4 |
WorkLifeBalance |
int | 1 (Bad) to 4 (Best) |
RelationshipSatisfaction |
int | 1 to 4 |
JobInvolvement |
int | 1 to 4 |
PerformanceRating |
int | 3 (Excellent) or 4 (Outstanding) |
PercentSalaryHike |
int | Last salary increase % |
StockOptionLevel |
int | 0 to 3 |
MaritalStatus |
str | Single, Married, Divorced |
Education |
int | 1 to 5 (Below College to Doctor) |
NumCompaniesWorked |
int | Previous employers |
TrainingTimesLastYear |
int | Training sessions attended |
Columns to Drop (No Analytical Value)¶
| Column | Why |
|---|---|
EmployeeCount |
Always 1 — constant |
StandardHours |
Always 80 — constant |
Over18 |
Always "Y" — constant |
EmployeeNumber |
Just an ID — not predictive |
Data Quality Notes¶
- No missing values in this dataset — but always verify.
- No duplicates expected (one row per employee).
- Encoded satisfaction scores (1-4) — remember these are ordinal, not continuous, when interpreting.
- Class imbalance: only 16% attrition. Important when building a model — accuracy alone is misleading (predicting "everyone stays" is 84% accurate but useless).
Quick Exploration¶
import pandas as pd
df = pd.read_csv("WA_Fn-UseC_-HR-Employee-Attrition.csv")
print(df.shape) # (1470, 35)
# Overall attrition rate
print(df["Attrition"].value_counts(normalize=True))
# No 0.839
# Yes 0.161
# Attrition by department
print(df.groupby("Department")["Attrition"].apply(lambda x: (x == "Yes").mean()).round(3))
# Human Resources 0.190
# Research & Development 0.138
# Sales 0.206
# Attrition by overtime
print(df.groupby("OverTime")["Attrition"].apply(lambda x: (x == "Yes").mean()).round(3))
# No 0.104
# Yes 0.305 ← overtime workers churn 3x more
The headline is visible immediately
Employees who work overtime have a 30.5% attrition rate vs 10.4% for those who don't — nearly 3×. Overtime is likely the single biggest actionable driver.