Can you help reduce employee turnover?
📖 Background
You work for the human capital department of a large corporation. The Board is worried about the relatively high turnover, and your team must look into ways to reduce the number of employees leaving the company.
The team needs to understand better the situation, which employees are more likely to leave, and why. Once it is clear what variables impact employee churn, you can present your findings along with your ideas on how to attack the problem.
💾 The data
The department has assembled data on almost 10,000 employees. The team used information from exit interviews, performance reviews, and employee records.
- "department" - the department the employee belongs to.
- "promoted" - 1 if the employee was promoted in the previous 24 months, 0 otherwise.
- "review" - the composite score the employee received in their last evaluation.
- "projects" - how many projects the employee is involved in.
- "salary" - for confidentiality reasons, salary comes in three tiers: low, medium, high.
- "tenure" - how many years the employee has been at the company.
- "satisfaction" - a measure of employee satisfaction from surveys.
- "avg_hrs_month" - the average hours the employee worked in a month.
- "left" - "yes" if the employee ended up leaving, "no" otherwise.
library(tidyverse)
df <- readr::read_csv('./data/employee_churn_data.csv')
head(df)
💪 Competition challenge
Create a report that covers the following:
- Which department has the highest employee turnover? Which one has the lowest?
- Investigate which variables seem to be better predictors of employee departure.
- What recommendations would you make regarding ways to reduce employee turnover?
🧑⚖️ Judging criteria
Recommendations (35%)
- Clarity of recommendations - how clear and well presented the recommendation is.
- Quality of recommendations - are appropriate analytic techniques used & are the conclusions valid?
- Number of relevant insights found for the target audience.
Storytelling (35%)
- How well the data and insights are connected to the recommendation.
- How the narrative and whole report connects together.
- Balancing making the report in-depth enough but also concise.
Visualizations (20%)
- Appropriateness of visualization used.
- Clarity of insight from visualization.
Upvotes (10%)
- Upvoting - most upvoted entries get the most points.
✅ Checklist before publishing into the competition
- Rename your workspace to make it descriptive of your work. N.B. you should leave the notebook name as notebook.Rmd.
- Remove redundant cells like the judging criteria, so the workbook is focused on your story.
- Make sure the workbook reads well and explains how you found your insights.
- Check that all the cells run without error.
⌛️ Time is ticking. Good luck!
1. Which department has the highest employee turnover? Which one has the lowest?
To analyse the employee turnover situation, we first group our data by departments and left ( have the left the company or not ) variable. We can them compute counts and percentages of employees that have left in each department.
The following plot shows the highest and lowest employee turnover. The IT department has the highest turnover, while the finance department has lowest employee turnover.
library('tidyverse')
library("plotly")
department_turnover <- function(X) {
summary.department.turnover = df %>% dplyr::group_by(department, left) %>% summarise(cnt = n()) %>% filter(department==X) %>%
mutate(per = formattable::percent(cnt / sum(cnt))) %>%
arrange(desc(per))
summary.department.turnover
leave.rate = summary.department.turnover[2,]
leave.rate }
turnover_data = as.data.frame(rbind(department_turnover("admin"), department_turnover("engineering"), department_turnover("finance"), department_turnover("IT"),
department_turnover("logistics"),department_turnover("marketing"), department_turnover("operations"), department_turnover("retail"), department_turnover("sales"),
department_turnover("support")))
turnover_data = turnover_data %>% arrange((per))
turnover_data$department = factor(turnover_data$department, levels = unique(turnover_data$department))
turnover.plot = ggplot(turnover_data, aes(x = department, y = per, group = 1)) + geom_line(col = "red") + ylab('Percentage of Employees that have left') + xlab("Departments") + theme_bw()
ggplotly(turnover.plot)
2. Investigate which variables seem to be better predictors of employee departure.
One way to investigate this to construct a correlation matrix.
install.packages("corrplot")
library(corrplot)
# Install fastDummies:
install.packages('fastDummies')
# Import fastDummies
library('fastDummies')
df$department = as.factor(df$department)
df$salary = as.factor(df$salary)
df$left = as.factor(df$left)
df$promoted = as.factor(df$promoted)
dataf <- dummy_cols(df, select_columns = c('department', 'salary', 'left', 'promoted'))
dataf = dataf %>% dplyr::select(-c(department, salary, left, promoted, department_admin, salary_low, promoted_0 ,left_no))
logit.model = glm(left ~ . , family = "binomial", data = df)
summary(logit.model)
install.packages("corrplot")
library(corrplot)
source("http://www.sthda.com/upload/rquery_cormat.r")
cor.data <- dataf
head(cor.data)
rquery.cormat(cor.data)
cor.df = rquery.cormat(dataf, type="flatten", graph=FALSE)
cor.df = cor.df %>% as.data.frame() %>% dplyr::filter(row == "left_yes")
install.packages("PerformanceAnalytics")
library(PerformanceAnalytics)
library("Hmisc")
res2 <- rcorr(as.matrix(dataf))