R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

# Load packages for analysis and this section will have all the required libraries mentioned for better clarity
library('ggplot2') # visualization
## Warning: package 'ggplot2' was built under R version 3.4.1
library('car') # visualization
## Warning: package 'car' was built under R version 3.4.2
library('scales') # visualization
## Warning: package 'scales' was built under R version 3.4.3
library('dplyr') # data manipulation
## Warning: package 'dplyr' was built under R version 3.4.2
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:car':
## 
##     recode
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# library('mice') # imputation
# library('randomForest') # classification algorithm
# library('rpart') # for decision tree
# library('tidyr')
# library('ROCR')
# library('randomForest')
# library('corrr')
# library('corrplot')
# library('glue')
# library('caTools')
# library('data.table')
# require("GGally")
# require("geosphere")
# require("gmapsdistance")
require("tidyr")
## Loading required package: tidyr
## Warning: package 'tidyr' was built under R version 3.4.3
library('corrplot')
## Warning: package 'corrplot' was built under R version 3.4.2
## corrplot 0.84 loaded
#source("distance.R")
library('car')
library('caret')
## Warning: package 'caret' was built under R version 3.4.3
## Loading required package: lattice
library('purrr')
## Warning: package 'purrr' was built under R version 3.4.3
## 
## Attaching package: 'purrr'
## The following object is masked from 'package:caret':
## 
##     lift
## The following object is masked from 'package:scales':
## 
##     discard
## The following object is masked from 'package:car':
## 
##     some
library('coefplot')
## Warning: package 'coefplot' was built under R version 3.4.4
library('psych')
## Warning: package 'psych' was built under R version 3.4.2
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:scales':
## 
##     alpha, rescale
## The following object is masked from 'package:car':
## 
##     logit
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
library('MASS')
## Warning: package 'MASS' was built under R version 3.4.3
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
library('leaflet.extras')
## Warning: package 'leaflet.extras' was built under R version 3.4.1
## Loading required package: leaflet
## Warning: package 'leaflet' was built under R version 3.4.1
library("PerformanceAnalytics")
## Warning: package 'PerformanceAnalytics' was built under R version 3.4.4
## Loading required package: xts
## Warning: package 'xts' was built under R version 3.4.4
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.4.3
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Attaching package: 'xts'
## The following object is masked from 'package:leaflet':
## 
##     addLegend
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
## 
##     legend
library('GPArotation')
## Warning: package 'GPArotation' was built under R version 3.4.1
library('MVN')
## Warning: package 'MVN' was built under R version 3.4.3
## sROC 0.1-2 loaded
library('psych')
library('MASS')
library('psy')
## Warning: package 'psy' was built under R version 3.4.1
## 
## Attaching package: 'psy'
## The following object is masked from 'package:psych':
## 
##     wkappa
library('corpcor')
## Warning: package 'corpcor' was built under R version 3.4.1
library('fastmatch')
## Warning: package 'fastmatch' was built under R version 3.4.1
## 
## Attaching package: 'fastmatch'
## The following object is masked from 'package:dplyr':
## 
##     coalesce
library('plyr')
## Warning: package 'plyr' was built under R version 3.4.1
## -------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## -------------------------------------------------------------------------
## 
## Attaching package: 'plyr'
## The following object is masked from 'package:purrr':
## 
##     compact
## The following objects are masked from 'package:dplyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
library('car')
library("PerformanceAnalytics")
library('ggcorrplot')
## Warning: package 'ggcorrplot' was built under R version 3.4.2
library('cluster')
## Warning: package 'cluster' was built under R version 3.4.2
library('caTools')
## Warning: package 'caTools' was built under R version 3.4.1
# library('InformationValue')
library('rpart.plot')
## Warning: package 'rpart.plot' was built under R version 3.4.3
## Loading required package: rpart
## Warning: package 'rpart' was built under R version 3.4.4
library('ggplot2')
library('RColorBrewer')
## Warning: package 'RColorBrewer' was built under R version 3.4.1
# library('data.table')
# library('ROCR')
# library('maptree')
# library('tree')
library('dummies') # for converting categorical into dummy one
## Warning: package 'dummies' was built under R version 3.4.1
## dummies-1.5.6 provided by Decision Patterns
library('caret')
library('pscl') ## for  McFadden R2
## Warning: package 'pscl' was built under R version 3.4.3
## Classes and Methods for R developed in the
## Political Science Computational Laboratory
## Department of Political Science
## Stanford University
## Simon Jackman
## hurdle and zeroinfl functions by Achim Zeileis
# library('randomForest')
library('StatMeasures')
## Warning: package 'StatMeasures' was built under R version 3.4.3
library('sqldf')
## Warning: package 'sqldf' was built under R version 3.4.3
## Loading required package: gsubfn
## Warning: package 'gsubfn' was built under R version 3.4.4
## Loading required package: proto
## Warning: package 'proto' was built under R version 3.4.1
## Loading required package: RSQLite
## Warning: package 'RSQLite' was built under R version 3.4.1
library('purrr')
library('tidyr')
library('caret')
library('ggplot2')
library('gains')
## Warning: package 'gains' was built under R version 3.4.1
library('lubridate')
## Warning: package 'lubridate' was built under R version 3.4.3
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:plyr':
## 
##     here
## The following object is masked from 'package:base':
## 
##     date
library('dummies')
library('glmnet')
## Warning: package 'glmnet' was built under R version 3.4.4
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 3.4.2
## 
## Attaching package: 'Matrix'
## The following object is masked from 'package:tidyr':
## 
##     expand
## Loading required package: foreach
## Warning: package 'foreach' was built under R version 3.4.3
## 
## Attaching package: 'foreach'
## The following objects are masked from 'package:purrr':
## 
##     accumulate, when
## Loaded glmnet 2.0-13
## 
## Attaching package: 'glmnet'
## The following object is masked from 'package:StatMeasures':
## 
##     auc

Data Unserstanding

Following are the data files we have and have summarized below understanding

Data File Name: intime Obsaervations: Each of the column name is the date and then for each column we have the in-time which is a date tome column. Here our primary key is the student id

Data File Name: employee_survery_data Observation: Here our primary key is student id. We have employee satisfaction data here

Data File Name: Outtime Obsaervations: Each of the column name is the date and then for each column we have the out-time which is a date time column. Here our primary key is the student id

Data File Name: general_data Obsaervations: Here our primary key is student Id and against id, we have all the values

Data Loading into Dataframe

employee_intime <-  read.csv('in_time.csv', stringsAsFactors = FALSE)
employee_outtime <- read.csv('out_time.csv')
employee_survey <-  read.csv('employee_survey_data.csv')
employee_general <- read.csv('general_data.csv')
manager_survery <- read.csv('manager_survey_data.csv')
  
 # summary(employee_intime)
 # summary(employee_outtime)
summary(employee_survey)
##    EmployeeID   EnvironmentSatisfaction JobSatisfaction WorkLifeBalance
##  Min.   :   1   Min.   :1.000           Min.   :1.000   Min.   :1.000  
##  1st Qu.:1103   1st Qu.:2.000           1st Qu.:2.000   1st Qu.:2.000  
##  Median :2206   Median :3.000           Median :3.000   Median :3.000  
##  Mean   :2206   Mean   :2.724           Mean   :2.728   Mean   :2.761  
##  3rd Qu.:3308   3rd Qu.:4.000           3rd Qu.:4.000   3rd Qu.:3.000  
##  Max.   :4410   Max.   :4.000           Max.   :4.000   Max.   :4.000  
##                 NA's   :25              NA's   :20      NA's   :38
summary(employee_general)
##       Age        Attrition            BusinessTravel
##  Min.   :18.00   No :3699   Non-Travel       : 450  
##  1st Qu.:30.00   Yes: 711   Travel_Frequently: 831  
##  Median :36.00              Travel_Rarely    :3129  
##  Mean   :36.92                                      
##  3rd Qu.:43.00                                      
##  Max.   :60.00                                      
##                                                     
##                   Department   DistanceFromHome   Education    
##  Human Resources       : 189   Min.   : 1.000   Min.   :1.000  
##  Research & Development:2883   1st Qu.: 2.000   1st Qu.:2.000  
##  Sales                 :1338   Median : 7.000   Median :3.000  
##                                Mean   : 9.193   Mean   :2.913  
##                                3rd Qu.:14.000   3rd Qu.:4.000  
##                                Max.   :29.000   Max.   :5.000  
##                                                                
##           EducationField EmployeeCount   EmployeeID      Gender    
##  Human Resources :  81   Min.   :1     Min.   :   1   Female:1764  
##  Life Sciences   :1818   1st Qu.:1     1st Qu.:1103   Male  :2646  
##  Marketing       : 477   Median :1     Median :2206                
##  Medical         :1392   Mean   :1     Mean   :2206                
##  Other           : 246   3rd Qu.:1     3rd Qu.:3308                
##  Technical Degree: 396   Max.   :1     Max.   :4410                
##                                                                    
##     JobLevel                          JobRole     MaritalStatus 
##  Min.   :1.000   Sales Executive          :978   Divorced: 981  
##  1st Qu.:1.000   Research Scientist       :876   Married :2019  
##  Median :2.000   Laboratory Technician    :777   Single  :1410  
##  Mean   :2.064   Manufacturing Director   :435                  
##  3rd Qu.:3.000   Healthcare Representative:393                  
##  Max.   :5.000   Manager                  :306                  
##                  (Other)                  :645                  
##  MonthlyIncome    NumCompaniesWorked Over18   PercentSalaryHike
##  Min.   : 10090   Min.   :0.000      Y:4410   Min.   :11.00    
##  1st Qu.: 29110   1st Qu.:1.000               1st Qu.:12.00    
##  Median : 49190   Median :2.000               Median :14.00    
##  Mean   : 65029   Mean   :2.695               Mean   :15.21    
##  3rd Qu.: 83800   3rd Qu.:4.000               3rd Qu.:18.00    
##  Max.   :199990   Max.   :9.000               Max.   :25.00    
##                   NA's   :19                                   
##  StandardHours StockOptionLevel TotalWorkingYears TrainingTimesLastYear
##  Min.   :8     Min.   :0.0000   Min.   : 0.00     Min.   :0.000        
##  1st Qu.:8     1st Qu.:0.0000   1st Qu.: 6.00     1st Qu.:2.000        
##  Median :8     Median :1.0000   Median :10.00     Median :3.000        
##  Mean   :8     Mean   :0.7939   Mean   :11.28     Mean   :2.799        
##  3rd Qu.:8     3rd Qu.:1.0000   3rd Qu.:15.00     3rd Qu.:3.000        
##  Max.   :8     Max.   :3.0000   Max.   :40.00     Max.   :6.000        
##                                 NA's   :9                              
##  YearsAtCompany   YearsSinceLastPromotion YearsWithCurrManager
##  Min.   : 0.000   Min.   : 0.000          Min.   : 0.000      
##  1st Qu.: 3.000   1st Qu.: 0.000          1st Qu.: 2.000      
##  Median : 5.000   Median : 1.000          Median : 3.000      
##  Mean   : 7.008   Mean   : 2.188          Mean   : 4.123      
##  3rd Qu.: 9.000   3rd Qu.: 3.000          3rd Qu.: 7.000      
##  Max.   :40.000   Max.   :15.000          Max.   :17.000      
## 

Data Transformation

First step of our data transformation will be to streamline in-time and out-time. As part of our data transformation, we will merge merge employee_general and employee_survey by employee id.

Our next step of data transformation is to merge the in-time and out-time based on student id. But here the catch is that the date is the column heading.. So we will calculate the daily time as long they stayed in office and then weekly average hours they sent in office. We have initially converted excluded the Employee Id columns and have converted all other columns into date. Next we need to find out how we calculate daily hours spent in office.

nrow(employee_general)
## [1] 4410
consolidated_employee <- merge(employee_general,employee_survey, by='EmployeeID')
consolidated_employee <- merge(consolidated_employee,manager_survery, by='EmployeeID')


nrow(consolidated_employee)
## [1] 4410
ncol(employee_intime)
## [1] 262
employee_intime[, 2:261] <- sapply(employee_intime[, 2:261], strptime, format = "%Y-%m-%d %H:%M:%S")
employee_outtime[, 2:261] <- sapply(employee_outtime[, 2:261], strptime, format = "%Y-%m-%d %H:%M:%S")
employee_atttendance_details <- employee_outtime[, 2:261] -  employee_intime[, 2:261]

# as.numeric(employee_atttendance_details[, 1:260], units="hours")
employee_atttendance_details[, 1:260] <- sapply(employee_atttendance_details[, 1:260] , as.numeric, units = "hours")
ncol(employee_atttendance_details)
## [1] 260
employee_atttendance_details$office_duration=rowMeans(employee_atttendance_details[,1:260], na.rm=TRUE)
employee_atttendance_sumamry <- as.data.frame(cbind(employee_intime$X, employee_atttendance_details$office_duration))

Further Data enreachment

Our next step will be to merge employee_atttendance_details and employee_general. We only need to take office_duration from attendance data as of now.

names(employee_atttendance_sumamry)[names(employee_atttendance_sumamry) == 'V1'] <- 'EmployeeID'
names(employee_atttendance_sumamry)[names(employee_atttendance_sumamry) == 'V2'] <- 'OfficeAvgduration'
consolidated_employee <- merge(consolidated_employee,employee_atttendance_sumamry, by='EmployeeID')

## now drop 

Data Visualisation for variables

Density plot will help us to understand the data distribution pattern

consolidated_employee_backup <- consolidated_employee  ## taking a backup here

consolidated_employee %>%
  keep(is.numeric) %>%                     # Keep only numeric columns
  gather() %>%                             # Convert to key-value pairs
  ggplot(aes(value)) +                     # Plot the values
    facet_wrap(~ key, scales = "free") +   # In separate panels
    geom_density()                         # as density
## Warning: Removed 111 rows containing non-finite values (stat_density).

### Doing the histogram here

consolidated_employee %>%
  keep(is.numeric) %>% 
  gather() %>% 
  ggplot(aes(value)) +
    facet_wrap(~ key, scales = "free") +
    geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 111 rows containing non-finite values (stat_bin).

## Doing the boxplot here
dk <- c(1,14)
boxplot(subset(consolidated_employee, select = -dk), las = 2)

p<-ggplot(consolidated_employee, aes(subset(consolidated_employee, select = -dk),color=Gender, fill=Department)) + geom_boxplot()

Data Consolidation for model

Now we have the consolidated data and lets do basic plotting to understanding their relationship. Our result column is Attrition. Dummy variable conversion rules… # Attrition: Our priority is to prevent attrition and hene we will set Attrition as 1 and No Attrition as 0. Key observation here is that data is biassed towards “No Attrition” We will use the dummies package for converting into dummy variable. Some of the variables which are having level encoding is being corrected below so that dummy variables can be developped later, Otherwise model will assume than as numeric value.

str(consolidated_employee)
## 'data.frame':    4410 obs. of  30 variables:
##  $ EmployeeID             : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ Age                    : int  51 31 32 38 32 46 28 29 31 25 ...
##  $ Attrition              : Factor w/ 2 levels "No","Yes": 1 2 1 1 1 1 2 1 1 1 ...
##  $ BusinessTravel         : Factor w/ 3 levels "Non-Travel","Travel_Frequently",..: 3 2 2 1 3 3 3 3 3 1 ...
##  $ Department             : Factor w/ 3 levels "Human Resources",..: 3 2 2 2 2 2 2 2 2 2 ...
##  $ DistanceFromHome       : int  6 10 17 2 10 8 11 18 1 7 ...
##  $ Education              : int  2 1 4 5 1 3 2 3 3 4 ...
##  $ EducationField         : Factor w/ 6 levels "Human Resources",..: 2 2 5 2 4 2 4 2 2 4 ...
##  $ EmployeeCount          : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ Gender                 : Factor w/ 2 levels "Female","Male": 1 1 2 2 2 1 2 2 2 1 ...
##  $ JobLevel               : int  1 1 4 3 1 4 2 2 3 4 ...
##  $ JobRole                : Factor w/ 9 levels "Healthcare Representative",..: 1 7 8 2 8 6 8 8 3 3 ...
##  $ MaritalStatus          : Factor w/ 3 levels "Divorced","Married",..: 2 3 2 2 3 2 3 2 2 1 ...
##  $ MonthlyIncome          : int  131160 41890 193280 83210 23420 40710 58130 31430 20440 134640 ...
##  $ NumCompaniesWorked     : int  1 0 1 3 4 3 2 2 0 1 ...
##  $ Over18                 : Factor w/ 1 level "Y": 1 1 1 1 1 1 1 1 1 1 ...
##  $ PercentSalaryHike      : int  11 23 15 11 12 13 20 22 21 13 ...
##  $ StandardHours          : int  8 8 8 8 8 8 8 8 8 8 ...
##  $ StockOptionLevel       : int  0 1 3 3 2 0 1 3 0 1 ...
##  $ TotalWorkingYears      : int  1 6 5 13 9 28 5 10 10 6 ...
##  $ TrainingTimesLastYear  : int  6 3 2 5 2 5 2 2 2 2 ...
##  $ YearsAtCompany         : int  1 5 5 8 6 7 0 0 9 6 ...
##  $ YearsSinceLastPromotion: int  0 1 0 7 0 7 0 0 7 1 ...
##  $ YearsWithCurrManager   : int  0 4 3 5 4 7 0 0 8 5 ...
##  $ EnvironmentSatisfaction: int  3 3 2 4 4 3 1 1 2 2 ...
##  $ JobSatisfaction        : int  4 2 2 4 1 2 3 2 4 1 ...
##  $ WorkLifeBalance        : int  2 4 1 3 3 2 1 3 3 3 ...
##  $ JobInvolvement         : int  3 2 3 2 3 3 3 3 3 3 ...
##  $ PerformanceRating      : int  3 4 3 3 3 3 4 4 4 3 ...
##  $ OfficeAvgduration      : num  7.37 7.72 7.01 7.19 8.01 ...
##Attrition
consolidated_employee$Attrition <- ifelse(consolidated_employee$Attrition == "Yes",1,0)
table(consolidated_employee$Attrition)
## 
##    0    1 
## 3699  711
##Job satisfaction transformation
consolidated_employee$JobSatisfaction[consolidated_employee$JobSatisfaction==1] <- 'Low'
consolidated_employee$JobSatisfaction[consolidated_employee$JobSatisfaction==2] <- 'Medium'
consolidated_employee$JobSatisfaction[consolidated_employee$JobSatisfaction==3] <- 'High'
consolidated_employee$JobSatisfaction[consolidated_employee$JobSatisfaction==4] <- 'VeryHigh'



##Performance Rating transformation
consolidated_employee$PerformanceRating[consolidated_employee$PerformanceRating==1] <- 'Low'
consolidated_employee$PerformanceRating[consolidated_employee$PerformanceRating==2] <- 'Good'
consolidated_employee$PerformanceRating[consolidated_employee$PerformanceRating==3] <- 'Excellent'
consolidated_employee$PerformanceRating[consolidated_employee$PerformanceRating==4] <- 'Outstanding'

### Job Involvement transformation
consolidated_employee$JobInvolvement[consolidated_employee$JobInvolvement==1] <- 'Low'
consolidated_employee$JobInvolvement[consolidated_employee$JobInvolvement==2] <- 'Medium'
consolidated_employee$JobInvolvement[consolidated_employee$JobInvolvement==3] <- 'High'
consolidated_employee$JobInvolvement[consolidated_employee$JobInvolvement==4] <- 'VeryHigh'

### Education transformation
consolidated_employee$Education[consolidated_employee$Education==1] <- 'BelowCollege'
consolidated_employee$Education[consolidated_employee$Education==2] <- 'College'
consolidated_employee$Education[consolidated_employee$Education==3] <- 'Bachelor'
consolidated_employee$Education[consolidated_employee$Education==4] <- 'Master'
consolidated_employee$Education[consolidated_employee$Education==5] <- 'Doctor'

### worklife balance transformation
consolidated_employee$WorkLifeBalance[consolidated_employee$WorkLifeBalance==1] <- 'Bad'
consolidated_employee$WorkLifeBalance[consolidated_employee$WorkLifeBalance==2] <- 'Good'
consolidated_employee$WorkLifeBalance[consolidated_employee$WorkLifeBalance==3] <- 'Better'
consolidated_employee$WorkLifeBalance[consolidated_employee$WorkLifeBalance==4] <- 'Best'



consolidated_employee <- dummy.data.frame(consolidated_employee[,-1], sep = ".")
str(consolidated_employee)
## 'data.frame':    4410 obs. of  64 variables:
##  $ Age                              : int  51 31 32 38 32 46 28 29 31 25 ...
##  $ Attrition                        : num  0 1 0 0 0 0 1 0 0 0 ...
##  $ BusinessTravel.Non-Travel        : int  0 0 0 1 0 0 0 0 0 1 ...
##  $ BusinessTravel.Travel_Frequently : int  0 1 1 0 0 0 0 0 0 0 ...
##  $ BusinessTravel.Travel_Rarely     : int  1 0 0 0 1 1 1 1 1 0 ...
##  $ Department.Human Resources       : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ Department.Research & Development: int  0 1 1 1 1 1 1 1 1 1 ...
##  $ Department.Sales                 : int  1 0 0 0 0 0 0 0 0 0 ...
##  $ DistanceFromHome                 : int  6 10 17 2 10 8 11 18 1 7 ...
##  $ Education.Bachelor               : int  0 0 0 0 0 1 0 1 1 0 ...
##  $ Education.BelowCollege           : int  0 1 0 0 1 0 0 0 0 0 ...
##  $ Education.College                : int  1 0 0 0 0 0 1 0 0 0 ...
##  $ Education.Doctor                 : int  0 0 0 1 0 0 0 0 0 0 ...
##  $ Education.Master                 : int  0 0 1 0 0 0 0 0 0 1 ...
##  $ EducationField.Human Resources   : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ EducationField.Life Sciences     : int  1 1 0 1 0 1 0 1 1 0 ...
##  $ EducationField.Marketing         : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ EducationField.Medical           : int  0 0 0 0 1 0 1 0 0 1 ...
##  $ EducationField.Other             : int  0 0 1 0 0 0 0 0 0 0 ...
##  $ EducationField.Technical Degree  : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ EmployeeCount                    : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ Gender.Female                    : int  1 1 0 0 0 1 0 0 0 1 ...
##  $ Gender.Male                      : int  0 0 1 1 1 0 1 1 1 0 ...
##  $ JobLevel                         : int  1 1 4 3 1 4 2 2 3 4 ...
##  $ JobRole.Healthcare Representative: int  1 0 0 0 0 0 0 0 0 0 ...
##  $ JobRole.Human Resources          : int  0 0 0 1 0 0 0 0 0 0 ...
##  $ JobRole.Laboratory Technician    : int  0 0 0 0 0 0 0 0 1 1 ...
##  $ JobRole.Manager                  : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ JobRole.Manufacturing Director   : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ JobRole.Research Director        : int  0 0 0 0 0 1 0 0 0 0 ...
##  $ JobRole.Research Scientist       : int  0 1 0 0 0 0 0 0 0 0 ...
##  $ JobRole.Sales Executive          : int  0 0 1 0 1 0 1 1 0 0 ...
##  $ JobRole.Sales Representative     : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ MaritalStatus.Divorced           : int  0 0 0 0 0 0 0 0 0 1 ...
##  $ MaritalStatus.Married            : int  1 0 1 1 0 1 0 1 1 0 ...
##  $ MaritalStatus.Single             : int  0 1 0 0 1 0 1 0 0 0 ...
##  $ MonthlyIncome                    : int  131160 41890 193280 83210 23420 40710 58130 31430 20440 134640 ...
##  $ NumCompaniesWorked               : int  1 0 1 3 4 3 2 2 0 1 ...
##  $ PercentSalaryHike                : int  11 23 15 11 12 13 20 22 21 13 ...
##  $ StandardHours                    : int  8 8 8 8 8 8 8 8 8 8 ...
##  $ StockOptionLevel                 : int  0 1 3 3 2 0 1 3 0 1 ...
##  $ TotalWorkingYears                : int  1 6 5 13 9 28 5 10 10 6 ...
##  $ TrainingTimesLastYear            : int  6 3 2 5 2 5 2 2 2 2 ...
##  $ YearsAtCompany                   : int  1 5 5 8 6 7 0 0 9 6 ...
##  $ YearsSinceLastPromotion          : int  0 1 0 7 0 7 0 0 7 1 ...
##  $ YearsWithCurrManager             : int  0 4 3 5 4 7 0 0 8 5 ...
##  $ EnvironmentSatisfaction          : int  3 3 2 4 4 3 1 1 2 2 ...
##  $ JobSatisfaction.High             : int  0 0 0 0 0 0 1 0 0 0 ...
##  $ JobSatisfaction.Low              : int  0 0 0 0 1 0 0 0 0 1 ...
##  $ JobSatisfaction.Medium           : int  0 1 1 0 0 1 0 1 0 0 ...
##  $ JobSatisfaction.VeryHigh         : int  1 0 0 1 0 0 0 0 1 0 ...
##  $ JobSatisfaction.NA               : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ WorkLifeBalance.Bad              : int  0 0 1 0 0 0 1 0 0 0 ...
##  $ WorkLifeBalance.Best             : int  0 1 0 0 0 0 0 0 0 0 ...
##  $ WorkLifeBalance.Better           : int  0 0 0 1 1 0 0 1 1 1 ...
##  $ WorkLifeBalance.Good             : int  1 0 0 0 0 1 0 0 0 0 ...
##  $ WorkLifeBalance.NA               : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ JobInvolvement.High              : int  1 0 1 0 1 1 1 1 1 1 ...
##  $ JobInvolvement.Low               : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ JobInvolvement.Medium            : int  0 1 0 1 0 0 0 0 0 0 ...
##  $ JobInvolvement.VeryHigh          : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ PerformanceRating.Excellent      : int  1 0 1 1 1 1 0 0 0 1 ...
##  $ PerformanceRating.Outstanding    : int  0 1 0 0 0 0 1 1 1 0 ...
##  $ OfficeAvgduration                : num  7.37 7.72 7.01 7.19 8.01 ...
##  - attr(*, "dummies")=List of 11
##   ..$ BusinessTravel   : int  3 4 5
##   ..$ Department       : int  6 7 8
##   ..$ Education        : int  10 11 12 13 14
##   ..$ EducationField   : int  15 16 17 18 19 20
##   ..$ Gender           : int  22 23
##   ..$ JobRole          : int  25 26 27 28 29 30 31 32 33
##   ..$ MaritalStatus    : int  34 35 36
##   ..$ JobSatisfaction  : int  48 49 50 51 52
##   ..$ WorkLifeBalance  : int  53 54 55 56 57
##   ..$ JobInvolvement   : int  58 59 60 61
##   ..$ PerformanceRating: int  62 63
summary(consolidated_employee)
##       Age          Attrition      BusinessTravel.Non-Travel
##  Min.   :18.00   Min.   :0.0000   Min.   :0.000            
##  1st Qu.:30.00   1st Qu.:0.0000   1st Qu.:0.000            
##  Median :36.00   Median :0.0000   Median :0.000            
##  Mean   :36.92   Mean   :0.1612   Mean   :0.102            
##  3rd Qu.:43.00   3rd Qu.:0.0000   3rd Qu.:0.000            
##  Max.   :60.00   Max.   :1.0000   Max.   :1.000            
##                                                            
##  BusinessTravel.Travel_Frequently BusinessTravel.Travel_Rarely
##  Min.   :0.0000                   Min.   :0.0000              
##  1st Qu.:0.0000                   1st Qu.:0.0000              
##  Median :0.0000                   Median :1.0000              
##  Mean   :0.1884                   Mean   :0.7095              
##  3rd Qu.:0.0000                   3rd Qu.:1.0000              
##  Max.   :1.0000                   Max.   :1.0000              
##                                                               
##  Department.Human Resources Department.Research & Development
##  Min.   :0.00000            Min.   :0.0000                   
##  1st Qu.:0.00000            1st Qu.:0.0000                   
##  Median :0.00000            Median :1.0000                   
##  Mean   :0.04286            Mean   :0.6537                   
##  3rd Qu.:0.00000            3rd Qu.:1.0000                   
##  Max.   :1.00000            Max.   :1.0000                   
##                                                              
##  Department.Sales DistanceFromHome Education.Bachelor
##  Min.   :0.0000   Min.   : 1.000   Min.   :0.0000    
##  1st Qu.:0.0000   1st Qu.: 2.000   1st Qu.:0.0000    
##  Median :0.0000   Median : 7.000   Median :0.0000    
##  Mean   :0.3034   Mean   : 9.193   Mean   :0.3891    
##  3rd Qu.:1.0000   3rd Qu.:14.000   3rd Qu.:1.0000    
##  Max.   :1.0000   Max.   :29.000   Max.   :1.0000    
##                                                      
##  Education.BelowCollege Education.College Education.Doctor 
##  Min.   :0.0000         Min.   :0.0000    Min.   :0.00000  
##  1st Qu.:0.0000         1st Qu.:0.0000    1st Qu.:0.00000  
##  Median :0.0000         Median :0.0000    Median :0.00000  
##  Mean   :0.1156         Mean   :0.1918    Mean   :0.03265  
##  3rd Qu.:0.0000         3rd Qu.:0.0000    3rd Qu.:0.00000  
##  Max.   :1.0000         Max.   :1.0000    Max.   :1.00000  
##                                                            
##  Education.Master EducationField.Human Resources
##  Min.   :0.0000   Min.   :0.00000               
##  1st Qu.:0.0000   1st Qu.:0.00000               
##  Median :0.0000   Median :0.00000               
##  Mean   :0.2707   Mean   :0.01837               
##  3rd Qu.:1.0000   3rd Qu.:0.00000               
##  Max.   :1.0000   Max.   :1.00000               
##                                                 
##  EducationField.Life Sciences EducationField.Marketing
##  Min.   :0.0000               Min.   :0.0000          
##  1st Qu.:0.0000               1st Qu.:0.0000          
##  Median :0.0000               Median :0.0000          
##  Mean   :0.4122               Mean   :0.1082          
##  3rd Qu.:1.0000               3rd Qu.:0.0000          
##  Max.   :1.0000               Max.   :1.0000          
##                                                       
##  EducationField.Medical EducationField.Other
##  Min.   :0.0000         Min.   :0.00000     
##  1st Qu.:0.0000         1st Qu.:0.00000     
##  Median :0.0000         Median :0.00000     
##  Mean   :0.3156         Mean   :0.05578     
##  3rd Qu.:1.0000         3rd Qu.:0.00000     
##  Max.   :1.0000         Max.   :1.00000     
##                                             
##  EducationField.Technical Degree EmployeeCount Gender.Female  Gender.Male 
##  Min.   :0.0000                  Min.   :1     Min.   :0.0   Min.   :0.0  
##  1st Qu.:0.0000                  1st Qu.:1     1st Qu.:0.0   1st Qu.:0.0  
##  Median :0.0000                  Median :1     Median :0.0   Median :1.0  
##  Mean   :0.0898                  Mean   :1     Mean   :0.4   Mean   :0.6  
##  3rd Qu.:0.0000                  3rd Qu.:1     3rd Qu.:1.0   3rd Qu.:1.0  
##  Max.   :1.0000                  Max.   :1     Max.   :1.0   Max.   :1.0  
##                                                                           
##     JobLevel     JobRole.Healthcare Representative JobRole.Human Resources
##  Min.   :1.000   Min.   :0.00000                   Min.   :0.00000        
##  1st Qu.:1.000   1st Qu.:0.00000                   1st Qu.:0.00000        
##  Median :2.000   Median :0.00000                   Median :0.00000        
##  Mean   :2.064   Mean   :0.08912                   Mean   :0.03537        
##  3rd Qu.:3.000   3rd Qu.:0.00000                   3rd Qu.:0.00000        
##  Max.   :5.000   Max.   :1.00000                   Max.   :1.00000        
##                                                                           
##  JobRole.Laboratory Technician JobRole.Manager  
##  Min.   :0.0000                Min.   :0.00000  
##  1st Qu.:0.0000                1st Qu.:0.00000  
##  Median :0.0000                Median :0.00000  
##  Mean   :0.1762                Mean   :0.06939  
##  3rd Qu.:0.0000                3rd Qu.:0.00000  
##  Max.   :1.0000                Max.   :1.00000  
##                                                 
##  JobRole.Manufacturing Director JobRole.Research Director
##  Min.   :0.00000                Min.   :0.00000          
##  1st Qu.:0.00000                1st Qu.:0.00000          
##  Median :0.00000                Median :0.00000          
##  Mean   :0.09864                Mean   :0.05442          
##  3rd Qu.:0.00000                3rd Qu.:0.00000          
##  Max.   :1.00000                Max.   :1.00000          
##                                                          
##  JobRole.Research Scientist JobRole.Sales Executive
##  Min.   :0.0000             Min.   :0.0000         
##  1st Qu.:0.0000             1st Qu.:0.0000         
##  Median :0.0000             Median :0.0000         
##  Mean   :0.1986             Mean   :0.2218         
##  3rd Qu.:0.0000             3rd Qu.:0.0000         
##  Max.   :1.0000             Max.   :1.0000         
##                                                    
##  JobRole.Sales Representative MaritalStatus.Divorced MaritalStatus.Married
##  Min.   :0.00000              Min.   :0.0000         Min.   :0.0000       
##  1st Qu.:0.00000              1st Qu.:0.0000         1st Qu.:0.0000       
##  Median :0.00000              Median :0.0000         Median :0.0000       
##  Mean   :0.05646              Mean   :0.2224         Mean   :0.4578       
##  3rd Qu.:0.00000              3rd Qu.:0.0000         3rd Qu.:1.0000       
##  Max.   :1.00000              Max.   :1.0000         Max.   :1.0000       
##                                                                           
##  MaritalStatus.Single MonthlyIncome    NumCompaniesWorked
##  Min.   :0.0000       Min.   : 10090   Min.   :0.000     
##  1st Qu.:0.0000       1st Qu.: 29110   1st Qu.:1.000     
##  Median :0.0000       Median : 49190   Median :2.000     
##  Mean   :0.3197       Mean   : 65029   Mean   :2.695     
##  3rd Qu.:1.0000       3rd Qu.: 83800   3rd Qu.:4.000     
##  Max.   :1.0000       Max.   :199990   Max.   :9.000     
##                                        NA's   :19        
##  PercentSalaryHike StandardHours StockOptionLevel TotalWorkingYears
##  Min.   :11.00     Min.   :8     Min.   :0.0000   Min.   : 0.00    
##  1st Qu.:12.00     1st Qu.:8     1st Qu.:0.0000   1st Qu.: 6.00    
##  Median :14.00     Median :8     Median :1.0000   Median :10.00    
##  Mean   :15.21     Mean   :8     Mean   :0.7939   Mean   :11.28    
##  3rd Qu.:18.00     3rd Qu.:8     3rd Qu.:1.0000   3rd Qu.:15.00    
##  Max.   :25.00     Max.   :8     Max.   :3.0000   Max.   :40.00    
##                                                   NA's   :9        
##  TrainingTimesLastYear YearsAtCompany   YearsSinceLastPromotion
##  Min.   :0.000         Min.   : 0.000   Min.   : 0.000         
##  1st Qu.:2.000         1st Qu.: 3.000   1st Qu.: 0.000         
##  Median :3.000         Median : 5.000   Median : 1.000         
##  Mean   :2.799         Mean   : 7.008   Mean   : 2.188         
##  3rd Qu.:3.000         3rd Qu.: 9.000   3rd Qu.: 3.000         
##  Max.   :6.000         Max.   :40.000   Max.   :15.000         
##                                                                
##  YearsWithCurrManager EnvironmentSatisfaction JobSatisfaction.High
##  Min.   : 0.000       Min.   :1.000           Min.   :0.0         
##  1st Qu.: 2.000       1st Qu.:2.000           1st Qu.:0.0         
##  Median : 3.000       Median :3.000           Median :0.0         
##  Mean   : 4.123       Mean   :2.724           Mean   :0.3         
##  3rd Qu.: 7.000       3rd Qu.:4.000           3rd Qu.:1.0         
##  Max.   :17.000       Max.   :4.000           Max.   :1.0         
##                       NA's   :25                                  
##  JobSatisfaction.Low JobSatisfaction.Medium JobSatisfaction.VeryHigh
##  Min.   :0.000       Min.   :0.0000         Min.   :0.00            
##  1st Qu.:0.000       1st Qu.:0.0000         1st Qu.:0.00            
##  Median :0.000       Median :0.0000         Median :0.00            
##  Mean   :0.195       Mean   :0.1905         Mean   :0.31            
##  3rd Qu.:0.000       3rd Qu.:0.0000         3rd Qu.:1.00            
##  Max.   :1.000       Max.   :1.0000         Max.   :1.00            
##                                                                     
##  JobSatisfaction.NA WorkLifeBalance.Bad WorkLifeBalance.Best
##  Min.   :0.000000   Min.   :0.0000      Min.   :0.0000      
##  1st Qu.:0.000000   1st Qu.:0.0000      1st Qu.:0.0000      
##  Median :0.000000   Median :0.0000      Median :0.0000      
##  Mean   :0.004535   Mean   :0.0542      Mean   :0.1029      
##  3rd Qu.:0.000000   3rd Qu.:0.0000      3rd Qu.:0.0000      
##  Max.   :1.000000   Max.   :1.0000      Max.   :1.0000      
##                                                             
##  WorkLifeBalance.Better WorkLifeBalance.Good WorkLifeBalance.NA
##  Min.   :0.0000         Min.   :0.0000       Min.   :0.000000  
##  1st Qu.:0.0000         1st Qu.:0.0000       1st Qu.:0.000000  
##  Median :1.0000         Median :0.0000       Median :0.000000  
##  Mean   :0.6032         Mean   :0.2311       Mean   :0.008617  
##  3rd Qu.:1.0000         3rd Qu.:0.0000       3rd Qu.:0.000000  
##  Max.   :1.0000         Max.   :1.0000       Max.   :1.000000  
##                                                                
##  JobInvolvement.High JobInvolvement.Low JobInvolvement.Medium
##  Min.   :0.0000      Min.   :0.00000    Min.   :0.0000       
##  1st Qu.:0.0000      1st Qu.:0.00000    1st Qu.:0.0000       
##  Median :1.0000      Median :0.00000    Median :0.0000       
##  Mean   :0.5905      Mean   :0.05646    Mean   :0.2551       
##  3rd Qu.:1.0000      3rd Qu.:0.00000    3rd Qu.:1.0000       
##  Max.   :1.0000      Max.   :1.00000    Max.   :1.0000       
##                                                              
##  JobInvolvement.VeryHigh PerformanceRating.Excellent
##  Min.   :0.00000         Min.   :0.0000             
##  1st Qu.:0.00000         1st Qu.:1.0000             
##  Median :0.00000         Median :1.0000             
##  Mean   :0.09796         Mean   :0.8463             
##  3rd Qu.:0.00000         3rd Qu.:1.0000             
##  Max.   :1.00000         Max.   :1.0000             
##                                                     
##  PerformanceRating.Outstanding OfficeAvgduration
##  Min.   :0.0000                Min.   : 5.948   
##  1st Qu.:0.0000                1st Qu.: 6.673   
##  Median :0.0000                Median : 7.407   
##  Mean   :0.1537                Mean   : 7.701   
##  3rd Qu.:0.0000                3rd Qu.: 8.370   
##  Max.   :1.0000                Max.   :11.033   
## 

Splitting the data into Test and Training Mode

We will be doing the splitting here and then build the regression model

set.seed(34251)

pd_logit<-sample(2,nrow(consolidated_employee),replace=TRUE, prob=c(0.7,0.3))

consolidated_employee_regression_train<-consolidated_employee[pd_logit==1,]
consolidated_employee_regression_val<-consolidated_employee[pd_logit==2,]

nrow(consolidated_employee_regression_train)
## [1] 3071
nrow(consolidated_employee_regression_val)
## [1] 1339
reg_modelstudent <- glm(consolidated_employee_regression_train$Attrition ~.,family=binomial(link='logit'),data=consolidated_employee_regression_train)
summary(reg_modelstudent)
## 
## Call:
## glm(formula = consolidated_employee_regression_train$Attrition ~ 
##     ., family = binomial(link = "logit"), data = consolidated_employee_regression_train)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.7921  -0.5428  -0.3347  -0.1611   3.6985  
## 
## Coefficients: (13 not defined because of singularities)
##                                       Estimate Std. Error z value Pr(>|z|)
## (Intercept)                         -3.906e+00  1.597e+00  -2.446  0.01445
## Age                                 -2.766e-02  9.046e-03  -3.058  0.00223
## `BusinessTravel.Non-Travel`         -4.955e-01  2.317e-01  -2.139  0.03244
## BusinessTravel.Travel_Frequently     8.849e-01  1.347e-01   6.568 5.09e-11
## BusinessTravel.Travel_Rarely                NA         NA      NA       NA
## `Department.Human Resources`         8.690e-01  3.539e-01   2.455  0.01408
## `Department.Research & Development`  6.279e-02  1.536e-01   0.409  0.68266
## Department.Sales                            NA         NA      NA       NA
## DistanceFromHome                    -8.981e-04  7.351e-03  -0.122  0.90276
## Education.Bachelor                   5.028e-02  1.449e-01   0.347  0.72857
## Education.BelowCollege               1.329e-01  2.105e-01   0.631  0.52783
## Education.College                    2.368e-01  1.672e-01   1.417  0.15660
## Education.Doctor                    -7.350e-01  3.798e-01  -1.935  0.05294
## Education.Master                            NA         NA      NA       NA
## `EducationField.Human Resources`     8.917e-01  5.164e-01   1.727  0.08421
## `EducationField.Life Sciences`       3.101e-01  2.329e-01   1.332  0.18297
## EducationField.Marketing             2.321e-01  2.911e-01   0.797  0.42537
## EducationField.Medical               3.155e-01  2.381e-01   1.325  0.18514
## EducationField.Other                 1.569e-02  3.442e-01   0.046  0.96364
## `EducationField.Technical Degree`           NA         NA      NA       NA
## EmployeeCount                               NA         NA      NA       NA
## Gender.Female                       -1.322e-01  1.198e-01  -1.104  0.26973
## Gender.Male                                 NA         NA      NA       NA
## JobLevel                            -5.492e-02  5.317e-02  -1.033  0.30167
## `JobRole.Healthcare Representative`  2.925e-01  3.205e-01   0.913  0.36134
## `JobRole.Human Resources`            1.721e-01  4.030e-01   0.427  0.66933
## `JobRole.Laboratory Technician`      4.845e-01  2.909e-01   1.666  0.09581
## JobRole.Manager                      1.965e-01  3.456e-01   0.569  0.56961
## `JobRole.Manufacturing Director`    -2.922e-01  3.312e-01  -0.882  0.37776
## `JobRole.Research Director`          8.908e-01  3.467e-01   2.570  0.01018
## `JobRole.Research Scientist`         6.330e-01  2.858e-01   2.215  0.02674
## `JobRole.Sales Executive`            7.517e-01  2.821e-01   2.665  0.00771
## `JobRole.Sales Representative`              NA         NA      NA       NA
## MaritalStatus.Divorced              -1.191e+00  1.751e-01  -6.799 1.06e-11
## MaritalStatus.Married               -9.643e-01  1.290e-01  -7.477 7.61e-14
## MaritalStatus.Single                        NA         NA      NA       NA
## MonthlyIncome                       -1.290e-06  1.267e-06  -1.018  0.30851
## NumCompaniesWorked                   1.180e-01  2.505e-02   4.712 2.45e-06
## PercentSalaryHike                    3.905e-02  2.514e-02   1.553  0.12043
## StandardHours                               NA         NA      NA       NA
## StockOptionLevel                    -8.333e-02  6.799e-02  -1.226  0.22036
## TotalWorkingYears                   -8.240e-02  1.649e-02  -4.996 5.85e-07
## TrainingTimesLastYear               -1.398e-01  4.639e-02  -3.014  0.00258
## YearsAtCompany                       3.003e-02  2.312e-02   1.299  0.19395
## YearsSinceLastPromotion              1.840e-01  2.620e-02   7.023 2.17e-12
## YearsWithCurrManager                -1.797e-01  2.881e-02  -6.237 4.45e-10
## EnvironmentSatisfaction             -3.192e-01  5.266e-02  -6.063 1.34e-09
## JobSatisfaction.High                -1.256e-02  1.084e+00  -0.012  0.99076
## JobSatisfaction.Low                  4.841e-01  1.086e+00   0.446  0.65585
## JobSatisfaction.Medium              -4.733e-02  1.087e+00  -0.044  0.96526
## JobSatisfaction.VeryHigh            -6.866e-01  1.087e+00  -0.632  0.52768
## JobSatisfaction.NA                          NA         NA      NA       NA
## WorkLifeBalance.Bad                  2.007e+00  8.170e-01   2.457  0.01403
## WorkLifeBalance.Best                 8.566e-01  8.107e-01   1.057  0.29069
## WorkLifeBalance.Better               5.767e-01  7.959e-01   0.725  0.46869
## WorkLifeBalance.Good                 1.014e+00  8.008e-01   1.267  0.20532
## WorkLifeBalance.NA                          NA         NA      NA       NA
## JobInvolvement.High                 -2.559e-01  1.932e-01  -1.325  0.18526
## JobInvolvement.Low                   2.862e-01  2.768e-01   1.034  0.30119
## JobInvolvement.Medium               -1.174e-01  2.109e-01  -0.556  0.57790
## JobInvolvement.VeryHigh                     NA         NA      NA       NA
## PerformanceRating.Excellent          1.981e-01  2.489e-01   0.796  0.42604
## PerformanceRating.Outstanding               NA         NA      NA       NA
## OfficeAvgduration                    4.485e-01  4.103e-02  10.931  < 2e-16
##                                        
## (Intercept)                         *  
## Age                                 ** 
## `BusinessTravel.Non-Travel`         *  
## BusinessTravel.Travel_Frequently    ***
## BusinessTravel.Travel_Rarely           
## `Department.Human Resources`        *  
## `Department.Research & Development`    
## Department.Sales                       
## DistanceFromHome                       
## Education.Bachelor                     
## Education.BelowCollege                 
## Education.College                      
## Education.Doctor                    .  
## Education.Master                       
## `EducationField.Human Resources`    .  
## `EducationField.Life Sciences`         
## EducationField.Marketing               
## EducationField.Medical                 
## EducationField.Other                   
## `EducationField.Technical Degree`      
## EmployeeCount                          
## Gender.Female                          
## Gender.Male                            
## JobLevel                               
## `JobRole.Healthcare Representative`    
## `JobRole.Human Resources`              
## `JobRole.Laboratory Technician`     .  
## JobRole.Manager                        
## `JobRole.Manufacturing Director`       
## `JobRole.Research Director`         *  
## `JobRole.Research Scientist`        *  
## `JobRole.Sales Executive`           ** 
## `JobRole.Sales Representative`         
## MaritalStatus.Divorced              ***
## MaritalStatus.Married               ***
## MaritalStatus.Single                   
## MonthlyIncome                          
## NumCompaniesWorked                  ***
## PercentSalaryHike                      
## StandardHours                          
## StockOptionLevel                       
## TotalWorkingYears                   ***
## TrainingTimesLastYear               ** 
## YearsAtCompany                         
## YearsSinceLastPromotion             ***
## YearsWithCurrManager                ***
## EnvironmentSatisfaction             ***
## JobSatisfaction.High                   
## JobSatisfaction.Low                    
## JobSatisfaction.Medium                 
## JobSatisfaction.VeryHigh               
## JobSatisfaction.NA                     
## WorkLifeBalance.Bad                 *  
## WorkLifeBalance.Best                   
## WorkLifeBalance.Better                 
## WorkLifeBalance.Good                   
## WorkLifeBalance.NA                     
## JobInvolvement.High                    
## JobInvolvement.Low                     
## JobInvolvement.Medium                  
## JobInvolvement.VeryHigh                
## PerformanceRating.Excellent            
## PerformanceRating.Outstanding          
## OfficeAvgduration                   ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 2673.8  on 3035  degrees of freedom
## Residual deviance: 2040.9  on 2985  degrees of freedom
##   (35 observations deleted due to missingness)
## AIC: 2142.9
## 
## Number of Fisher Scoring iterations: 6

stepwise Logistic model

stepAIC method will be used to finetune the model further

stepAIC(reg_modelstudent, direction='both', steps = 1000, trace=TRUE)
## Start:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + EmployeeCount + Gender.Female + 
##     Gender.Male + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     `JobRole.Sales Representative` + MaritalStatus.Divorced + 
##     MaritalStatus.Married + MaritalStatus.Single + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StandardHours + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.High + JobSatisfaction.Low + 
##     JobSatisfaction.Medium + JobSatisfaction.VeryHigh + JobSatisfaction.NA + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + WorkLifeBalance.NA + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + JobInvolvement.VeryHigh + 
##     PerformanceRating.Excellent + PerformanceRating.Outstanding + 
##     OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + EmployeeCount + Gender.Female + 
##     Gender.Male + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     `JobRole.Sales Representative` + MaritalStatus.Divorced + 
##     MaritalStatus.Married + MaritalStatus.Single + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StandardHours + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.High + JobSatisfaction.Low + 
##     JobSatisfaction.Medium + JobSatisfaction.VeryHigh + JobSatisfaction.NA + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + WorkLifeBalance.NA + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + JobInvolvement.VeryHigh + 
##     PerformanceRating.Excellent + OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + EmployeeCount + Gender.Female + 
##     Gender.Male + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     `JobRole.Sales Representative` + MaritalStatus.Divorced + 
##     MaritalStatus.Married + MaritalStatus.Single + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StandardHours + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.High + JobSatisfaction.Low + 
##     JobSatisfaction.Medium + JobSatisfaction.VeryHigh + JobSatisfaction.NA + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + WorkLifeBalance.NA + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + PerformanceRating.Excellent + 
##     OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + EmployeeCount + Gender.Female + 
##     Gender.Male + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     `JobRole.Sales Representative` + MaritalStatus.Divorced + 
##     MaritalStatus.Married + MaritalStatus.Single + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StandardHours + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.High + JobSatisfaction.Low + 
##     JobSatisfaction.Medium + JobSatisfaction.VeryHigh + JobSatisfaction.NA + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##     JobInvolvement.Medium + PerformanceRating.Excellent + OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + EmployeeCount + Gender.Female + 
##     Gender.Male + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     `JobRole.Sales Representative` + MaritalStatus.Divorced + 
##     MaritalStatus.Married + MaritalStatus.Single + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StandardHours + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.High + JobSatisfaction.Low + 
##     JobSatisfaction.Medium + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Better + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + JobInvolvement.Medium + 
##     PerformanceRating.Excellent + OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + EmployeeCount + Gender.Female + 
##     Gender.Male + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     `JobRole.Sales Representative` + MaritalStatus.Divorced + 
##     MaritalStatus.Married + MaritalStatus.Single + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.High + JobSatisfaction.Low + JobSatisfaction.Medium + 
##     JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##     WorkLifeBalance.Better + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + PerformanceRating.Excellent + 
##     OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + EmployeeCount + Gender.Female + 
##     Gender.Male + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     `JobRole.Sales Representative` + MaritalStatus.Divorced + 
##     MaritalStatus.Married + MonthlyIncome + NumCompaniesWorked + 
##     PercentSalaryHike + StockOptionLevel + TotalWorkingYears + 
##     TrainingTimesLastYear + YearsAtCompany + YearsSinceLastPromotion + 
##     YearsWithCurrManager + EnvironmentSatisfaction + JobSatisfaction.High + 
##     JobSatisfaction.Low + JobSatisfaction.Medium + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##     JobInvolvement.Medium + PerformanceRating.Excellent + OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + EmployeeCount + Gender.Female + 
##     Gender.Male + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.High + JobSatisfaction.Low + JobSatisfaction.Medium + 
##     JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##     WorkLifeBalance.Better + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + PerformanceRating.Excellent + 
##     OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + EmployeeCount + Gender.Female + 
##     JobLevel + `JobRole.Healthcare Representative` + `JobRole.Human Resources` + 
##     `JobRole.Laboratory Technician` + JobRole.Manager + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.High + JobSatisfaction.Low + 
##     JobSatisfaction.Medium + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Better + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + JobInvolvement.Medium + 
##     PerformanceRating.Excellent + OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     `EducationField.Technical Degree` + Gender.Female + JobLevel + 
##     `JobRole.Healthcare Representative` + `JobRole.Human Resources` + 
##     `JobRole.Laboratory Technician` + JobRole.Manager + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.High + JobSatisfaction.Low + 
##     JobSatisfaction.Medium + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Better + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + JobInvolvement.Medium + 
##     PerformanceRating.Excellent + OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     Education.Master + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     Gender.Female + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.High + JobSatisfaction.Low + JobSatisfaction.Medium + 
##     JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##     WorkLifeBalance.Better + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + PerformanceRating.Excellent + 
##     OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     Department.Sales + DistanceFromHome + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     Gender.Female + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.High + JobSatisfaction.Low + JobSatisfaction.Medium + 
##     JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##     WorkLifeBalance.Better + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + PerformanceRating.Excellent + 
##     OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + BusinessTravel.Travel_Rarely + 
##     `Department.Human Resources` + `Department.Research & Development` + 
##     DistanceFromHome + Education.Bachelor + Education.BelowCollege + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Marketing + 
##     EducationField.Medical + EducationField.Other + Gender.Female + 
##     JobLevel + `JobRole.Healthcare Representative` + `JobRole.Human Resources` + 
##     `JobRole.Laboratory Technician` + JobRole.Manager + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.High + JobSatisfaction.Low + 
##     JobSatisfaction.Medium + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Better + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + JobInvolvement.Medium + 
##     PerformanceRating.Excellent + OfficeAvgduration
## 
## 
## Step:  AIC=2142.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     `Department.Research & Development` + DistanceFromHome + 
##     Education.Bachelor + Education.BelowCollege + Education.College + 
##     Education.Doctor + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     Gender.Female + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.High + JobSatisfaction.Low + JobSatisfaction.Medium + 
##     JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##     WorkLifeBalance.Better + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + PerformanceRating.Excellent + 
##     OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - JobSatisfaction.High                 1   2040.9 2140.9
## - JobSatisfaction.Medium               1   2040.9 2140.9
## - EducationField.Other                 1   2040.9 2140.9
## - DistanceFromHome                     1   2040.9 2140.9
## - Education.Bachelor                   1   2041.0 2141.0
## - `Department.Research & Development`  1   2041.1 2141.1
## - `JobRole.Human Resources`            1   2041.1 2141.1
## - JobSatisfaction.Low                  1   2041.1 2141.1
## - JobInvolvement.Medium                1   2041.2 2141.2
## - JobRole.Manager                      1   2041.2 2141.2
## - JobSatisfaction.VeryHigh             1   2041.2 2141.2
## - Education.BelowCollege               1   2041.3 2141.3
## - WorkLifeBalance.Better               1   2041.5 2141.5
## - PerformanceRating.Excellent          1   2041.5 2141.5
## - EducationField.Marketing             1   2041.5 2141.5
## - `JobRole.Manufacturing Director`     1   2041.7 2141.7
## - `JobRole.Healthcare Representative`  1   2041.8 2141.8
## - MonthlyIncome                        1   2042.0 2141.9
## - JobInvolvement.Low                   1   2042.0 2142.0
## - JobLevel                             1   2042.0 2142.0
## - Gender.Female                        1   2042.1 2142.1
## - WorkLifeBalance.Best                 1   2042.2 2142.2
## - StockOptionLevel                     1   2042.4 2142.4
## - YearsAtCompany                       1   2042.6 2142.6
## - JobInvolvement.High                  1   2042.6 2142.6
## - EducationField.Medical               1   2042.7 2142.7
## - `EducationField.Life Sciences`       1   2042.8 2142.8
## - WorkLifeBalance.Good                 1   2042.9 2142.9
## <none>                                     2040.9 2142.9
## - Education.College                    1   2042.9 2142.9
## - PercentSalaryHike                    1   2043.3 2143.3
## - `JobRole.Laboratory Technician`      1   2043.8 2143.8
## - `EducationField.Human Resources`     1   2043.9 2143.9
## - Education.Doctor                     1   2045.0 2145.0
## - `BusinessTravel.Non-Travel`          1   2045.8 2145.8
## - `JobRole.Research Scientist`         1   2046.1 2146.1
## - `Department.Human Resources`         1   2046.5 2146.5
## - `JobRole.Research Director`          1   2047.6 2147.6
## - `JobRole.Sales Executive`            1   2048.6 2148.6
## - WorkLifeBalance.Bad                  1   2049.4 2149.4
## - TrainingTimesLastYear                1   2050.2 2150.2
## - Age                                  1   2050.6 2150.6
## - NumCompaniesWorked                   1   2062.5 2162.5
## - TotalWorkingYears                    1   2068.9 2168.9
## - EnvironmentSatisfaction              1   2078.3 2178.3
## - YearsWithCurrManager                 1   2078.4 2178.4
## - BusinessTravel.Travel_Frequently     1   2082.9 2182.9
## - YearsSinceLastPromotion              1   2091.5 2191.5
## - MaritalStatus.Divorced               1   2092.1 2192.1
## - MaritalStatus.Married                1   2098.2 2198.2
## - OfficeAvgduration                    1   2164.0 2264.0
## 
## Step:  AIC=2140.9
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     `Department.Research & Development` + DistanceFromHome + 
##     Education.Bachelor + Education.BelowCollege + Education.College + 
##     Education.Doctor + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + EducationField.Other + 
##     Gender.Female + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.Medium + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##     JobInvolvement.Medium + PerformanceRating.Excellent + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - EducationField.Other                 1   2040.9 2138.9
## - DistanceFromHome                     1   2040.9 2138.9
## - JobSatisfaction.Medium               1   2041.0 2138.9
## - Education.Bachelor                   1   2041.0 2139.0
## - `Department.Research & Development`  1   2041.1 2139.1
## - `JobRole.Human Resources`            1   2041.1 2139.1
## - JobInvolvement.Medium                1   2041.2 2139.2
## - JobRole.Manager                      1   2041.2 2139.2
## - Education.BelowCollege               1   2041.3 2139.3
## - WorkLifeBalance.Better               1   2041.5 2139.5
## - PerformanceRating.Excellent          1   2041.5 2139.5
## - EducationField.Marketing             1   2041.5 2139.5
## - `JobRole.Manufacturing Director`     1   2041.7 2139.7
## - `JobRole.Healthcare Representative`  1   2041.8 2139.8
## - MonthlyIncome                        1   2042.0 2139.9
## - JobInvolvement.Low                   1   2042.0 2140.0
## - JobLevel                             1   2042.0 2140.0
## - Gender.Female                        1   2042.1 2140.1
## - WorkLifeBalance.Best                 1   2042.2 2140.2
## - StockOptionLevel                     1   2042.4 2140.4
## - YearsAtCompany                       1   2042.6 2140.6
## - JobInvolvement.High                  1   2042.6 2140.6
## - EducationField.Medical               1   2042.7 2140.7
## - `EducationField.Life Sciences`       1   2042.8 2140.8
## - WorkLifeBalance.Good                 1   2042.9 2140.9
## <none>                                     2040.9 2140.9
## - Education.College                    1   2042.9 2140.9
## - PercentSalaryHike                    1   2043.3 2141.3
## - `JobRole.Laboratory Technician`      1   2043.8 2141.8
## - `EducationField.Human Resources`     1   2043.9 2141.9
## + JobSatisfaction.High                 1   2040.9 2142.9
## + JobSatisfaction.NA                   1   2040.9 2142.9
## - Education.Doctor                     1   2045.0 2143.1
## - `BusinessTravel.Non-Travel`          1   2045.8 2143.8
## - `JobRole.Research Scientist`         1   2046.1 2144.1
## - `Department.Human Resources`         1   2046.5 2144.5
## - `JobRole.Research Director`          1   2047.6 2145.6
## - `JobRole.Sales Executive`            1   2048.6 2146.6
## - WorkLifeBalance.Bad                  1   2049.4 2147.4
## - TrainingTimesLastYear                1   2050.2 2148.2
## - Age                                  1   2050.6 2148.6
## - JobSatisfaction.Low                  1   2050.6 2148.6
## - JobSatisfaction.VeryHigh             1   2059.6 2157.6
## - NumCompaniesWorked                   1   2062.5 2160.5
## - TotalWorkingYears                    1   2068.9 2166.9
## - EnvironmentSatisfaction              1   2078.3 2176.3
## - YearsWithCurrManager                 1   2078.4 2176.4
## - BusinessTravel.Travel_Frequently     1   2082.9 2180.9
## - YearsSinceLastPromotion              1   2091.5 2189.5
## - MaritalStatus.Divorced               1   2092.1 2190.1
## - MaritalStatus.Married                1   2098.2 2196.2
## - OfficeAvgduration                    1   2164.0 2262.0
## 
## Step:  AIC=2138.91
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     `Department.Research & Development` + DistanceFromHome + 
##     Education.Bachelor + Education.BelowCollege + Education.College + 
##     Education.Doctor + `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + Gender.Female + 
##     JobLevel + `JobRole.Healthcare Representative` + `JobRole.Human Resources` + 
##     `JobRole.Laboratory Technician` + JobRole.Manager + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.Medium + 
##     JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##     WorkLifeBalance.Better + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + PerformanceRating.Excellent + 
##     OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - DistanceFromHome                     1   2040.9 2136.9
## - JobSatisfaction.Medium               1   2041.0 2136.9
## - Education.Bachelor                   1   2041.0 2137.0
## - `Department.Research & Development`  1   2041.1 2137.1
## - `JobRole.Human Resources`            1   2041.1 2137.1
## - JobInvolvement.Medium                1   2041.2 2137.2
## - JobRole.Manager                      1   2041.2 2137.2
## - Education.BelowCollege               1   2041.3 2137.3
## - WorkLifeBalance.Better               1   2041.5 2137.5
## - PerformanceRating.Excellent          1   2041.5 2137.5
## - EducationField.Marketing             1   2041.7 2137.7
## - `JobRole.Manufacturing Director`     1   2041.7 2137.7
## - `JobRole.Healthcare Representative`  1   2041.8 2137.8
## - MonthlyIncome                        1   2042.0 2138.0
## - JobInvolvement.Low                   1   2042.0 2138.0
## - JobLevel                             1   2042.0 2138.0
## - Gender.Female                        1   2042.1 2138.1
## - WorkLifeBalance.Best                 1   2042.2 2138.2
## - StockOptionLevel                     1   2042.4 2138.4
## - YearsAtCompany                       1   2042.6 2138.6
## - JobInvolvement.High                  1   2042.6 2138.6
## - WorkLifeBalance.Good                 1   2042.9 2138.9
## <none>                                     2040.9 2138.9
## - Education.College                    1   2042.9 2138.9
## - PercentSalaryHike                    1   2043.3 2139.3
## - EducationField.Medical               1   2043.5 2139.5
## - `EducationField.Life Sciences`       1   2043.6 2139.6
## - `JobRole.Laboratory Technician`      1   2043.8 2139.8
## - `EducationField.Human Resources`     1   2044.1 2140.1
## + EducationField.Other                 1   2040.9 2140.9
## + `EducationField.Technical Degree`    1   2040.9 2140.9
## + JobSatisfaction.High                 1   2040.9 2140.9
## + JobSatisfaction.NA                   1   2040.9 2140.9
## - Education.Doctor                     1   2045.1 2141.1
## - `BusinessTravel.Non-Travel`          1   2045.9 2141.9
## - `JobRole.Research Scientist`         1   2046.1 2142.1
## - `Department.Human Resources`         1   2046.5 2142.5
## - `JobRole.Research Director`          1   2047.6 2143.6
## - `JobRole.Sales Executive`            1   2048.6 2144.6
## - WorkLifeBalance.Bad                  1   2049.4 2145.4
## - TrainingTimesLastYear                1   2050.2 2146.2
## - Age                                  1   2050.6 2146.6
## - JobSatisfaction.Low                  1   2050.6 2146.6
## - JobSatisfaction.VeryHigh             1   2059.6 2155.6
## - NumCompaniesWorked                   1   2062.5 2158.5
## - TotalWorkingYears                    1   2069.0 2165.0
## - EnvironmentSatisfaction              1   2078.4 2174.4
## - YearsWithCurrManager                 1   2078.4 2174.4
## - BusinessTravel.Travel_Frequently     1   2083.2 2179.2
## - YearsSinceLastPromotion              1   2091.7 2187.7
## - MaritalStatus.Divorced               1   2092.2 2188.2
## - MaritalStatus.Married                1   2098.6 2194.6
## - OfficeAvgduration                    1   2164.0 2260.0
## 
## Step:  AIC=2136.92
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     `Department.Research & Development` + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + Gender.Female + 
##     JobLevel + `JobRole.Healthcare Representative` + `JobRole.Human Resources` + 
##     `JobRole.Laboratory Technician` + JobRole.Manager + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.Medium + 
##     JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##     WorkLifeBalance.Better + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + JobInvolvement.Medium + PerformanceRating.Excellent + 
##     OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - JobSatisfaction.Medium               1   2041.0 2135.0
## - Education.Bachelor                   1   2041.0 2135.0
## - `Department.Research & Development`  1   2041.1 2135.1
## - `JobRole.Human Resources`            1   2041.1 2135.1
## - JobInvolvement.Medium                1   2041.2 2135.2
## - JobRole.Manager                      1   2041.2 2135.2
## - Education.BelowCollege               1   2041.3 2135.3
## - WorkLifeBalance.Better               1   2041.5 2135.5
## - PerformanceRating.Excellent          1   2041.6 2135.6
## - EducationField.Marketing             1   2041.7 2135.7
## - `JobRole.Manufacturing Director`     1   2041.7 2135.7
## - `JobRole.Healthcare Representative`  1   2041.8 2135.8
## - MonthlyIncome                        1   2042.0 2136.0
## - JobLevel                             1   2042.0 2136.0
## - JobInvolvement.Low                   1   2042.0 2136.0
## - Gender.Female                        1   2042.2 2136.2
## - WorkLifeBalance.Best                 1   2042.2 2136.2
## - StockOptionLevel                     1   2042.4 2136.4
## - YearsAtCompany                       1   2042.6 2136.6
## - JobInvolvement.High                  1   2042.6 2136.6
## - WorkLifeBalance.Good                 1   2042.9 2136.9
## <none>                                     2040.9 2136.9
## - Education.College                    1   2042.9 2136.9
## - PercentSalaryHike                    1   2043.3 2137.3
## - EducationField.Medical               1   2043.5 2137.5
## - `EducationField.Life Sciences`       1   2043.6 2137.6
## - `JobRole.Laboratory Technician`      1   2043.8 2137.8
## - `EducationField.Human Resources`     1   2044.1 2138.1
## + DistanceFromHome                     1   2040.9 2138.9
## + EducationField.Other                 1   2040.9 2138.9
## + `EducationField.Technical Degree`    1   2040.9 2138.9
## + JobSatisfaction.High                 1   2040.9 2138.9
## + JobSatisfaction.NA                   1   2040.9 2138.9
## - Education.Doctor                     1   2045.1 2139.1
## - `BusinessTravel.Non-Travel`          1   2045.9 2139.9
## - `JobRole.Research Scientist`         1   2046.2 2140.2
## - `Department.Human Resources`         1   2046.5 2140.6
## - `JobRole.Research Director`          1   2047.6 2141.6
## - `JobRole.Sales Executive`            1   2048.6 2142.6
## - WorkLifeBalance.Bad                  1   2049.4 2143.4
## - TrainingTimesLastYear                1   2050.2 2144.2
## - JobSatisfaction.Low                  1   2050.6 2144.6
## - Age                                  1   2050.7 2144.7
## - JobSatisfaction.VeryHigh             1   2059.6 2153.6
## - NumCompaniesWorked                   1   2062.5 2156.5
## - TotalWorkingYears                    1   2069.0 2163.0
## - YearsWithCurrManager                 1   2078.5 2172.5
## - EnvironmentSatisfaction              1   2078.6 2172.6
## - BusinessTravel.Travel_Frequently     1   2083.3 2177.3
## - YearsSinceLastPromotion              1   2091.7 2185.7
## - MaritalStatus.Divorced               1   2092.3 2186.3
## - MaritalStatus.Married                1   2098.8 2192.8
## - OfficeAvgduration                    1   2164.1 2258.1
## 
## Step:  AIC=2134.97
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     `Department.Research & Development` + Education.Bachelor + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + Gender.Female + 
##     JobLevel + `JobRole.Healthcare Representative` + `JobRole.Human Resources` + 
##     `JobRole.Laboratory Technician` + JobRole.Manager + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##     JobInvolvement.Medium + PerformanceRating.Excellent + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - Education.Bachelor                   1   2041.1 2133.1
## - `Department.Research & Development`  1   2041.1 2133.1
## - `JobRole.Human Resources`            1   2041.1 2133.1
## - JobInvolvement.Medium                1   2041.3 2133.3
## - JobRole.Manager                      1   2041.3 2133.3
## - Education.BelowCollege               1   2041.3 2133.3
## - WorkLifeBalance.Better               1   2041.6 2133.6
## - PerformanceRating.Excellent          1   2041.6 2133.6
## - EducationField.Marketing             1   2041.7 2133.7
## - `JobRole.Manufacturing Director`     1   2041.8 2133.8
## - `JobRole.Healthcare Representative`  1   2041.8 2133.8
## - MonthlyIncome                        1   2042.0 2134.0
## - JobLevel                             1   2042.0 2134.0
## - JobInvolvement.Low                   1   2042.0 2134.0
## - Gender.Female                        1   2042.2 2134.2
## - WorkLifeBalance.Best                 1   2042.3 2134.3
## - StockOptionLevel                     1   2042.5 2134.5
## - YearsAtCompany                       1   2042.6 2134.6
## - JobInvolvement.High                  1   2042.7 2134.7
## - WorkLifeBalance.Good                 1   2042.9 2134.9
## <none>                                     2041.0 2135.0
## - Education.College                    1   2043.0 2135.0
## - PercentSalaryHike                    1   2043.4 2135.4
## - EducationField.Medical               1   2043.6 2135.6
## - `EducationField.Life Sciences`       1   2043.6 2135.6
## - `JobRole.Laboratory Technician`      1   2043.9 2135.9
## - `EducationField.Human Resources`     1   2044.2 2136.2
## + JobSatisfaction.Medium               1   2040.9 2136.9
## + JobSatisfaction.High                 1   2040.9 2136.9
## + DistanceFromHome                     1   2041.0 2136.9
## + EducationField.Other                 1   2041.0 2137.0
## + `EducationField.Technical Degree`    1   2041.0 2137.0
## + JobSatisfaction.NA                   1   2041.0 2137.0
## - Education.Doctor                     1   2045.2 2137.2
## - `BusinessTravel.Non-Travel`          1   2045.9 2137.9
## - `JobRole.Research Scientist`         1   2046.2 2138.2
## - `Department.Human Resources`         1   2046.6 2138.6
## - `JobRole.Research Director`          1   2047.7 2139.7
## - `JobRole.Sales Executive`            1   2048.7 2140.7
## - WorkLifeBalance.Bad                  1   2049.5 2141.5
## - TrainingTimesLastYear                1   2050.3 2142.3
## - Age                                  1   2050.7 2142.7
## - JobSatisfaction.Low                  1   2053.1 2145.1
## - NumCompaniesWorked                   1   2062.6 2154.6
## - JobSatisfaction.VeryHigh             1   2063.0 2155.0
## - TotalWorkingYears                    1   2069.0 2161.0
## - YearsWithCurrManager                 1   2078.5 2170.5
## - EnvironmentSatisfaction              1   2078.8 2170.8
## - BusinessTravel.Travel_Frequently     1   2083.5 2175.5
## - YearsSinceLastPromotion              1   2091.7 2183.7
## - MaritalStatus.Divorced               1   2092.3 2184.3
## - MaritalStatus.Married                1   2098.8 2190.8
## - OfficeAvgduration                    1   2164.1 2256.1
## 
## Step:  AIC=2133.08
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     `Department.Research & Development` + Education.BelowCollege + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Marketing + 
##     EducationField.Medical + Gender.Female + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Human Resources` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Better + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + JobInvolvement.Medium + 
##     PerformanceRating.Excellent + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - `JobRole.Human Resources`            1   2041.2 2131.2
## - `Department.Research & Development`  1   2041.3 2131.3
## - Education.BelowCollege               1   2041.3 2131.3
## - JobInvolvement.Medium                1   2041.4 2131.4
## - JobRole.Manager                      1   2041.4 2131.4
## - WorkLifeBalance.Better               1   2041.7 2131.7
## - PerformanceRating.Excellent          1   2041.8 2131.8
## - `JobRole.Manufacturing Director`     1   2041.9 2131.9
## - EducationField.Marketing             1   2041.9 2131.9
## - `JobRole.Healthcare Representative`  1   2042.0 2132.0
## - MonthlyIncome                        1   2042.1 2132.1
## - JobLevel                             1   2042.2 2132.2
## - JobInvolvement.Low                   1   2042.2 2132.2
## - Gender.Female                        1   2042.3 2132.3
## - WorkLifeBalance.Best                 1   2042.4 2132.4
## - StockOptionLevel                     1   2042.6 2132.6
## - JobInvolvement.High                  1   2042.8 2132.8
## - YearsAtCompany                       1   2042.8 2132.8
## - WorkLifeBalance.Good                 1   2043.1 2133.1
## <none>                                     2041.1 2133.1
## - Education.College                    1   2043.1 2133.1
## - PercentSalaryHike                    1   2043.5 2133.5
## - EducationField.Medical               1   2043.6 2133.6
## - `EducationField.Life Sciences`       1   2043.7 2133.7
## - `JobRole.Laboratory Technician`      1   2044.0 2134.0
## - `EducationField.Human Resources`     1   2044.3 2134.3
## + Education.Bachelor                   1   2041.0 2135.0
## + Education.Master                     1   2041.0 2135.0
## + JobSatisfaction.Medium               1   2041.0 2135.0
## + JobSatisfaction.High                 1   2041.0 2135.0
## + DistanceFromHome                     1   2041.1 2135.1
## + EducationField.Other                 1   2041.1 2135.1
## + `EducationField.Technical Degree`    1   2041.1 2135.1
## + JobSatisfaction.NA                   1   2041.1 2135.1
## - Education.Doctor                     1   2045.9 2135.9
## - `BusinessTravel.Non-Travel`          1   2046.0 2136.0
## - `JobRole.Research Scientist`         1   2046.3 2136.3
## - `Department.Human Resources`         1   2046.8 2136.8
## - `JobRole.Research Director`          1   2047.8 2137.8
## - `JobRole.Sales Executive`            1   2048.8 2138.8
## - WorkLifeBalance.Bad                  1   2049.6 2139.6
## - TrainingTimesLastYear                1   2050.3 2140.3
## - Age                                  1   2050.8 2140.8
## - JobSatisfaction.Low                  1   2053.3 2143.3
## - NumCompaniesWorked                   1   2062.7 2152.7
## - JobSatisfaction.VeryHigh             1   2063.3 2153.3
## - TotalWorkingYears                    1   2069.3 2159.3
## - YearsWithCurrManager                 1   2078.6 2168.6
## - EnvironmentSatisfaction              1   2078.9 2168.9
## - BusinessTravel.Travel_Frequently     1   2083.6 2173.6
## - YearsSinceLastPromotion              1   2091.8 2181.8
## - MaritalStatus.Divorced               1   2092.4 2182.4
## - MaritalStatus.Married                1   2098.9 2188.9
## - OfficeAvgduration                    1   2164.2 2254.2
## 
## Step:  AIC=2131.25
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     `Department.Research & Development` + Education.BelowCollege + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Marketing + 
##     EducationField.Medical + Gender.Female + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Laboratory Technician` + JobRole.Manager + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##     JobInvolvement.Medium + PerformanceRating.Excellent + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - `Department.Research & Development`  1   2041.4 2129.4
## - JobRole.Manager                      1   2041.5 2129.5
## - Education.BelowCollege               1   2041.5 2129.5
## - JobInvolvement.Medium                1   2041.6 2129.6
## - WorkLifeBalance.Better               1   2041.8 2129.8
## - PerformanceRating.Excellent          1   2041.9 2129.9
## - `JobRole.Healthcare Representative`  1   2042.0 2130.0
## - EducationField.Marketing             1   2042.1 2130.1
## - MonthlyIncome                        1   2042.3 2130.3
## - JobLevel                             1   2042.3 2130.3
## - JobInvolvement.Low                   1   2042.3 2130.3
## - Gender.Female                        1   2042.5 2130.5
## - WorkLifeBalance.Best                 1   2042.6 2130.6
## - StockOptionLevel                     1   2042.8 2130.8
## - `JobRole.Manufacturing Director`     1   2042.8 2130.8
## - YearsAtCompany                       1   2042.9 2130.9
## - JobInvolvement.High                  1   2043.0 2131.0
## - WorkLifeBalance.Good                 1   2043.2 2131.2
## <none>                                     2041.2 2131.2
## - Education.College                    1   2043.3 2131.3
## - PercentSalaryHike                    1   2043.6 2131.6
## - EducationField.Medical               1   2043.8 2131.8
## - `EducationField.Life Sciences`       1   2044.0 2131.9
## - `JobRole.Laboratory Technician`      1   2044.4 2132.4
## - `EducationField.Human Resources`     1   2044.4 2132.4
## + `JobRole.Human Resources`            1   2041.1 2133.1
## + `JobRole.Sales Representative`       1   2041.1 2133.1
## + Education.Bachelor                   1   2041.1 2133.1
## + Education.Master                     1   2041.1 2133.1
## + JobSatisfaction.Medium               1   2041.2 2133.2
## + JobSatisfaction.High                 1   2041.2 2133.2
## + DistanceFromHome                     1   2041.2 2133.2
## + JobSatisfaction.NA                   1   2041.2 2133.2
## + EducationField.Other                 1   2041.2 2133.2
## + `EducationField.Technical Degree`    1   2041.2 2133.2
## - Education.Doctor                     1   2046.0 2134.0
## - `BusinessTravel.Non-Travel`          1   2046.2 2134.2
## - `Department.Human Resources`         1   2047.0 2135.0
## - `JobRole.Research Scientist`         1   2047.4 2135.4
## - `JobRole.Research Director`          1   2048.5 2136.5
## - WorkLifeBalance.Bad                  1   2049.8 2137.8
## - TrainingTimesLastYear                1   2050.7 2138.7
## - `JobRole.Sales Executive`            1   2050.7 2138.7
## - Age                                  1   2051.1 2139.1
## - JobSatisfaction.Low                  1   2053.3 2141.3
## - NumCompaniesWorked                   1   2063.0 2151.0
## - JobSatisfaction.VeryHigh             1   2063.6 2151.6
## - TotalWorkingYears                    1   2069.3 2157.3
## - YearsWithCurrManager                 1   2078.7 2166.7
## - EnvironmentSatisfaction              1   2079.1 2167.1
## - BusinessTravel.Travel_Frequently     1   2084.0 2172.0
## - YearsSinceLastPromotion              1   2092.0 2180.0
## - MaritalStatus.Divorced               1   2093.1 2181.1
## - MaritalStatus.Married                1   2099.0 2187.0
## - OfficeAvgduration                    1   2164.2 2252.2
## 
## Step:  AIC=2129.44
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + Gender.Female + 
##     JobLevel + `JobRole.Healthcare Representative` + `JobRole.Laboratory Technician` + 
##     JobRole.Manager + `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Better + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + JobInvolvement.Medium + 
##     PerformanceRating.Excellent + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - JobRole.Manager                      1   2041.6 2127.6
## - Education.BelowCollege               1   2041.7 2127.7
## - JobInvolvement.Medium                1   2041.8 2127.8
## - WorkLifeBalance.Better               1   2042.0 2128.0
## - PerformanceRating.Excellent          1   2042.1 2128.1
## - EducationField.Marketing             1   2042.1 2128.1
## - `JobRole.Healthcare Representative`  1   2042.1 2128.1
## - MonthlyIncome                        1   2042.4 2128.4
## - JobInvolvement.Low                   1   2042.5 2128.5
## - JobLevel                             1   2042.5 2128.5
## - Gender.Female                        1   2042.7 2128.7
## - WorkLifeBalance.Best                 1   2042.8 2128.8
## - `JobRole.Manufacturing Director`     1   2043.0 2129.0
## - StockOptionLevel                     1   2043.0 2129.0
## - YearsAtCompany                       1   2043.1 2129.1
## - JobInvolvement.High                  1   2043.1 2129.1
## - Education.College                    1   2043.4 2129.4
## - WorkLifeBalance.Good                 1   2043.4 2129.4
## <none>                                     2041.4 2129.4
## - PercentSalaryHike                    1   2043.8 2129.8
## - `EducationField.Life Sciences`       1   2044.2 2130.2
## - EducationField.Medical               1   2044.2 2130.2
## - `JobRole.Laboratory Technician`      1   2044.5 2130.6
## - `EducationField.Human Resources`     1   2044.6 2130.6
## + `Department.Research & Development`  1   2041.2 2131.2
## + Department.Sales                     1   2041.2 2131.2
## + `JobRole.Human Resources`            1   2041.3 2131.3
## + `JobRole.Sales Representative`       1   2041.3 2131.3
## + Education.Bachelor                   1   2041.3 2131.3
## + Education.Master                     1   2041.3 2131.3
## + JobSatisfaction.Medium               1   2041.4 2131.4
## + JobSatisfaction.High                 1   2041.4 2131.4
## + DistanceFromHome                     1   2041.4 2131.4
## + JobSatisfaction.NA                   1   2041.4 2131.4
## + EducationField.Other                 1   2041.4 2131.4
## + `EducationField.Technical Degree`    1   2041.4 2131.4
## - Education.Doctor                     1   2046.2 2132.2
## - `BusinessTravel.Non-Travel`          1   2046.4 2132.4
## - `Department.Human Resources`         1   2047.0 2133.0
## - `JobRole.Research Scientist`         1   2047.5 2133.5
## - `JobRole.Research Director`          1   2048.7 2134.7
## - WorkLifeBalance.Bad                  1   2050.0 2136.0
## - `JobRole.Sales Executive`            1   2050.8 2136.8
## - TrainingTimesLastYear                1   2050.9 2136.9
## - Age                                  1   2051.4 2137.4
## - JobSatisfaction.Low                  1   2053.4 2139.4
## - NumCompaniesWorked                   1   2063.4 2149.4
## - JobSatisfaction.VeryHigh             1   2063.8 2149.8
## - TotalWorkingYears                    1   2069.4 2155.4
## - YearsWithCurrManager                 1   2078.8 2164.8
## - EnvironmentSatisfaction              1   2079.4 2165.4
## - BusinessTravel.Travel_Frequently     1   2084.0 2170.0
## - YearsSinceLastPromotion              1   2092.0 2178.0
## - MaritalStatus.Divorced               1   2093.2 2179.2
## - MaritalStatus.Married                1   2099.1 2185.1
## - OfficeAvgduration                    1   2164.9 2250.9
## 
## Step:  AIC=2127.64
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.BelowCollege + Education.College + Education.Doctor + 
##     `EducationField.Human Resources` + `EducationField.Life Sciences` + 
##     EducationField.Marketing + EducationField.Medical + Gender.Female + 
##     JobLevel + `JobRole.Healthcare Representative` + `JobRole.Laboratory Technician` + 
##     `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Better + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + JobInvolvement.Medium + 
##     PerformanceRating.Excellent + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - Education.BelowCollege               1   2041.9 2125.9
## - JobInvolvement.Medium                1   2042.0 2126.0
## - `JobRole.Healthcare Representative`  1   2042.1 2126.1
## - WorkLifeBalance.Better               1   2042.2 2126.2
## - PerformanceRating.Excellent          1   2042.3 2126.3
## - EducationField.Marketing             1   2042.3 2126.3
## - MonthlyIncome                        1   2042.6 2126.6
## - JobLevel                             1   2042.7 2126.7
## - JobInvolvement.Low                   1   2042.8 2126.8
## - Gender.Female                        1   2042.8 2126.8
## - WorkLifeBalance.Best                 1   2043.0 2127.0
## - StockOptionLevel                     1   2043.3 2127.3
## - JobInvolvement.High                  1   2043.3 2127.3
## - YearsAtCompany                       1   2043.4 2127.4
## - Education.College                    1   2043.6 2127.6
## - WorkLifeBalance.Good                 1   2043.6 2127.6
## <none>                                     2041.6 2127.6
## - PercentSalaryHike                    1   2043.9 2127.9
## - `JobRole.Manufacturing Director`     1   2044.3 2128.3
## - EducationField.Medical               1   2044.4 2128.4
## - `EducationField.Life Sciences`       1   2044.4 2128.4
## - `JobRole.Laboratory Technician`      1   2044.8 2128.8
## - `EducationField.Human Resources`     1   2044.9 2128.9
## + `JobRole.Sales Representative`       1   2041.3 2129.3
## + JobRole.Manager                      1   2041.4 2129.4
## + `Department.Research & Development`  1   2041.5 2129.5
## + Department.Sales                     1   2041.5 2129.5
## + Education.Bachelor                   1   2041.5 2129.5
## + Education.Master                     1   2041.5 2129.5
## + JobSatisfaction.Medium               1   2041.6 2129.6
## + JobSatisfaction.High                 1   2041.6 2129.6
## + `JobRole.Human Resources`            1   2041.6 2129.6
## + DistanceFromHome                     1   2041.6 2129.6
## + JobSatisfaction.NA                   1   2041.6 2129.6
## + EducationField.Other                 1   2041.6 2129.6
## + `EducationField.Technical Degree`    1   2041.6 2129.6
## - Education.Doctor                     1   2046.4 2130.4
## - `BusinessTravel.Non-Travel`          1   2046.6 2130.6
## - `Department.Human Resources`         1   2047.1 2131.1
## - `JobRole.Research Scientist`         1   2048.5 2132.5
## - `JobRole.Research Director`          1   2049.2 2133.2
## - WorkLifeBalance.Bad                  1   2050.1 2134.1
## - TrainingTimesLastYear                1   2051.1 2135.1
## - Age                                  1   2051.7 2135.7
## - `JobRole.Sales Executive`            1   2052.7 2136.7
## - JobSatisfaction.Low                  1   2053.5 2137.5
## - NumCompaniesWorked                   1   2063.4 2147.4
## - JobSatisfaction.VeryHigh             1   2064.3 2148.3
## - TotalWorkingYears                    1   2069.5 2153.5
## - YearsWithCurrManager                 1   2079.2 2163.2
## - EnvironmentSatisfaction              1   2079.7 2163.7
## - BusinessTravel.Travel_Frequently     1   2084.6 2168.6
## - YearsSinceLastPromotion              1   2092.4 2176.4
## - MaritalStatus.Divorced               1   2093.5 2177.5
## - MaritalStatus.Married                1   2100.0 2184.0
## - OfficeAvgduration                    1   2165.0 2249.0
## 
## Step:  AIC=2125.92
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Marketing + 
##     EducationField.Medical + Gender.Female + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##     JobInvolvement.Medium + PerformanceRating.Excellent + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - JobInvolvement.Medium                1   2042.2 2124.2
## - `JobRole.Healthcare Representative`  1   2042.4 2124.4
## - PerformanceRating.Excellent          1   2042.5 2124.5
## - WorkLifeBalance.Better               1   2042.5 2124.6
## - EducationField.Marketing             1   2042.6 2124.6
## - MonthlyIncome                        1   2042.9 2124.9
## - JobInvolvement.Low                   1   2043.0 2125.0
## - Gender.Female                        1   2043.1 2125.1
## - JobLevel                             1   2043.1 2125.1
## - WorkLifeBalance.Best                 1   2043.3 2125.3
## - StockOptionLevel                     1   2043.5 2125.6
## - YearsAtCompany                       1   2043.6 2125.6
## - JobInvolvement.High                  1   2043.6 2125.6
## - Education.College                    1   2043.7 2125.7
## <none>                                     2041.9 2125.9
## - WorkLifeBalance.Good                 1   2044.0 2126.0
## - PercentSalaryHike                    1   2044.2 2126.2
## - `JobRole.Manufacturing Director`     1   2044.5 2126.5
## - `EducationField.Life Sciences`       1   2044.6 2126.6
## - EducationField.Medical               1   2044.7 2126.7
## - `EducationField.Human Resources`     1   2045.2 2127.2
## - `JobRole.Laboratory Technician`      1   2045.3 2127.3
## + `JobRole.Sales Representative`       1   2041.6 2127.6
## + Education.BelowCollege               1   2041.6 2127.6
## + Education.Master                     1   2041.7 2127.7
## + JobRole.Manager                      1   2041.7 2127.7
## + `Department.Research & Development`  1   2041.7 2127.7
## + Department.Sales                     1   2041.7 2127.7
## + JobSatisfaction.Medium               1   2041.9 2127.9
## + JobSatisfaction.High                 1   2041.9 2127.9
## + `JobRole.Human Resources`            1   2041.9 2127.9
## + Education.Bachelor                   1   2041.9 2127.9
## + DistanceFromHome                     1   2041.9 2127.9
## + JobSatisfaction.NA                   1   2041.9 2127.9
## + EducationField.Other                 1   2041.9 2127.9
## + `EducationField.Technical Degree`    1   2041.9 2127.9
## - Education.Doctor                     1   2046.8 2128.8
## - `BusinessTravel.Non-Travel`          1   2046.9 2128.9
## - `Department.Human Resources`         1   2047.4 2129.4
## - `JobRole.Research Scientist`         1   2049.0 2131.0
## - `JobRole.Research Director`          1   2049.5 2131.5
## - WorkLifeBalance.Bad                  1   2050.6 2132.6
## - TrainingTimesLastYear                1   2051.5 2133.5
## - Age                                  1   2051.9 2133.9
## - `JobRole.Sales Executive`            1   2053.2 2135.2
## - JobSatisfaction.Low                  1   2053.7 2135.7
## - NumCompaniesWorked                   1   2063.7 2145.7
## - JobSatisfaction.VeryHigh             1   2064.8 2146.8
## - TotalWorkingYears                    1   2069.8 2151.8
## - YearsWithCurrManager                 1   2079.4 2161.4
## - EnvironmentSatisfaction              1   2079.9 2161.9
## - BusinessTravel.Travel_Frequently     1   2084.8 2166.8
## - YearsSinceLastPromotion              1   2092.7 2174.7
## - MaritalStatus.Divorced               1   2093.7 2175.7
## - MaritalStatus.Married                1   2100.0 2182.0
## - OfficeAvgduration                    1   2166.4 2248.4
## 
## Step:  AIC=2124.23
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Marketing + 
##     EducationField.Medical + Gender.Female + JobLevel + `JobRole.Healthcare Representative` + 
##     `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Better + 
##     WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##     PerformanceRating.Excellent + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - `JobRole.Healthcare Representative`  1   2042.8 2122.8
## - PerformanceRating.Excellent          1   2042.8 2122.8
## - WorkLifeBalance.Better               1   2042.9 2122.9
## - EducationField.Marketing             1   2042.9 2122.9
## - MonthlyIncome                        1   2043.2 2123.2
## - Gender.Female                        1   2043.4 2123.4
## - JobLevel                             1   2043.5 2123.5
## - WorkLifeBalance.Best                 1   2043.6 2123.6
## - StockOptionLevel                     1   2043.9 2123.9
## - YearsAtCompany                       1   2043.9 2123.9
## - Education.College                    1   2044.0 2124.0
## - JobInvolvement.High                  1   2044.2 2124.2
## <none>                                     2042.2 2124.2
## - WorkLifeBalance.Good                 1   2044.3 2124.3
## - PercentSalaryHike                    1   2044.5 2124.5
## - JobInvolvement.Low                   1   2044.6 2124.6
## - `JobRole.Manufacturing Director`     1   2044.7 2124.7
## - EducationField.Medical               1   2045.0 2125.0
## - `EducationField.Life Sciences`       1   2045.0 2125.0
## - `EducationField.Human Resources`     1   2045.5 2125.4
## - `JobRole.Laboratory Technician`      1   2045.8 2125.8
## + `JobRole.Sales Representative`       1   2041.9 2125.9
## + JobInvolvement.Medium                1   2041.9 2125.9
## + JobInvolvement.VeryHigh              1   2041.9 2125.9
## + Education.Master                     1   2042.0 2125.9
## + Education.BelowCollege               1   2042.0 2126.0
## + JobRole.Manager                      1   2042.0 2126.0
## + `Department.Research & Development`  1   2042.0 2126.0
## + Department.Sales                     1   2042.0 2126.0
## + JobSatisfaction.Medium               1   2042.2 2126.2
## + JobSatisfaction.High                 1   2042.2 2126.2
## + `JobRole.Human Resources`            1   2042.2 2126.2
## + Education.Bachelor                   1   2042.2 2126.2
## + DistanceFromHome                     1   2042.2 2126.2
## + EducationField.Other                 1   2042.2 2126.2
## + `EducationField.Technical Degree`    1   2042.2 2126.2
## + JobSatisfaction.NA                   1   2042.2 2126.2
## - Education.Doctor                     1   2047.1 2127.1
## - `BusinessTravel.Non-Travel`          1   2047.3 2127.3
## - `Department.Human Resources`         1   2047.8 2127.8
## - `JobRole.Research Scientist`         1   2049.4 2129.4
## - `JobRole.Research Director`          1   2050.2 2130.2
## - WorkLifeBalance.Bad                  1   2050.8 2130.8
## - TrainingTimesLastYear                1   2051.7 2131.7
## - Age                                  1   2052.0 2132.0
## - `JobRole.Sales Executive`            1   2053.6 2133.6
## - JobSatisfaction.Low                  1   2054.0 2134.0
## - NumCompaniesWorked                   1   2064.1 2144.1
## - JobSatisfaction.VeryHigh             1   2065.1 2145.1
## - TotalWorkingYears                    1   2070.4 2150.4
## - YearsWithCurrManager                 1   2079.8 2159.8
## - EnvironmentSatisfaction              1   2080.3 2160.3
## - BusinessTravel.Travel_Frequently     1   2085.2 2165.2
## - YearsSinceLastPromotion              1   2093.2 2173.2
## - MaritalStatus.Divorced               1   2093.9 2173.9
## - MaritalStatus.Married                1   2101.0 2181.0
## - OfficeAvgduration                    1   2166.5 2246.5
## 
## Step:  AIC=2122.79
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Marketing + 
##     EducationField.Medical + Gender.Female + JobLevel + `JobRole.Laboratory Technician` + 
##     `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Better + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + PerformanceRating.Excellent + 
##     OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - PerformanceRating.Excellent          1   2043.3 2121.3
## - WorkLifeBalance.Better               1   2043.4 2121.4
## - EducationField.Marketing             1   2043.4 2121.4
## - MonthlyIncome                        1   2043.8 2121.8
## - JobLevel                             1   2044.0 2122.0
## - Gender.Female                        1   2044.0 2122.0
## - WorkLifeBalance.Best                 1   2044.1 2122.1
## - StockOptionLevel                     1   2044.4 2122.4
## - YearsAtCompany                       1   2044.4 2122.4
## - Education.College                    1   2044.6 2122.6
## - WorkLifeBalance.Good                 1   2044.8 2122.8
## - JobInvolvement.High                  1   2044.8 2122.8
## <none>                                     2042.8 2122.8
## - PercentSalaryHike                    1   2045.0 2123.0
## - JobInvolvement.Low                   1   2045.2 2123.2
## - `EducationField.Life Sciences`       1   2045.5 2123.5
## - EducationField.Medical               1   2045.5 2123.5
## - `JobRole.Laboratory Technician`      1   2045.8 2123.8
## - `EducationField.Human Resources`     1   2046.0 2124.0
## + `JobRole.Sales Representative`       1   2042.0 2124.0
## + `JobRole.Healthcare Representative`  1   2042.2 2124.2
## + JobInvolvement.Medium                1   2042.4 2124.4
## + JobInvolvement.VeryHigh              1   2042.4 2124.4
## + Education.Master                     1   2042.5 2124.5
## + Education.BelowCollege               1   2042.5 2124.5
## + `Department.Research & Development`  1   2042.6 2124.6
## + Department.Sales                     1   2042.6 2124.6
## - `JobRole.Manufacturing Director`     1   2046.7 2124.7
## + Education.Bachelor                   1   2042.8 2124.8
## + JobSatisfaction.Medium               1   2042.8 2124.8
## + JobSatisfaction.High                 1   2042.8 2124.8
## + JobRole.Manager                      1   2042.8 2124.8
## + `JobRole.Human Resources`            1   2042.8 2124.8
## + DistanceFromHome                     1   2042.8 2124.8
## + EducationField.Other                 1   2042.8 2124.8
## + `EducationField.Technical Degree`    1   2042.8 2124.8
## + JobSatisfaction.NA                   1   2042.8 2124.8
## - Education.Doctor                     1   2047.8 2125.8
## - `BusinessTravel.Non-Travel`          1   2047.9 2125.9
## - `Department.Human Resources`         1   2048.3 2126.3
## - `JobRole.Research Scientist`         1   2049.7 2127.7
## - `JobRole.Research Director`          1   2050.2 2128.2
## - WorkLifeBalance.Bad                  1   2051.3 2129.3
## - TrainingTimesLastYear                1   2052.5 2130.5
## - Age                                  1   2052.9 2130.9
## - `JobRole.Sales Executive`            1   2054.3 2132.3
## - JobSatisfaction.Low                  1   2054.6 2132.6
## - NumCompaniesWorked                   1   2064.7 2142.7
## - JobSatisfaction.VeryHigh             1   2065.5 2143.5
## - TotalWorkingYears                    1   2070.8 2148.8
## - YearsWithCurrManager                 1   2080.1 2158.1
## - EnvironmentSatisfaction              1   2080.7 2158.7
## - BusinessTravel.Travel_Frequently     1   2085.7 2163.7
## - YearsSinceLastPromotion              1   2094.0 2172.0
## - MaritalStatus.Divorced               1   2094.3 2172.3
## - MaritalStatus.Married                1   2101.1 2179.1
## - OfficeAvgduration                    1   2167.0 2245.0
## 
## Step:  AIC=2121.34
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Marketing + 
##     EducationField.Medical + Gender.Female + JobLevel + `JobRole.Laboratory Technician` + 
##     `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Better + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - WorkLifeBalance.Better               1   2043.9 2119.9
## - EducationField.Marketing             1   2044.0 2120.0
## - MonthlyIncome                        1   2044.4 2120.4
## - JobLevel                             1   2044.5 2120.5
## - Gender.Female                        1   2044.5 2120.5
## - WorkLifeBalance.Best                 1   2044.6 2120.6
## - StockOptionLevel                     1   2044.8 2120.8
## - YearsAtCompany                       1   2044.9 2120.9
## - Education.College                    1   2045.1 2121.1
## - WorkLifeBalance.Good                 1   2045.3 2121.3
## <none>                                     2043.3 2121.3
## - JobInvolvement.High                  1   2045.4 2121.4
## - PercentSalaryHike                    1   2045.5 2121.5
## - JobInvolvement.Low                   1   2045.7 2121.7
## - EducationField.Medical               1   2046.0 2122.1
## - `EducationField.Life Sciences`       1   2046.1 2122.1
## - `JobRole.Laboratory Technician`      1   2046.4 2122.4
## - `EducationField.Human Resources`     1   2046.6 2122.6
## + `JobRole.Sales Representative`       1   2042.6 2122.6
## + PerformanceRating.Excellent          1   2042.8 2122.8
## + PerformanceRating.Outstanding        1   2042.8 2122.8
## + `JobRole.Healthcare Representative`  1   2042.8 2122.8
## + JobInvolvement.Medium                1   2043.0 2123.0
## + JobInvolvement.VeryHigh              1   2043.0 2123.0
## + Education.Master                     1   2043.0 2123.0
## + Education.BelowCollege               1   2043.0 2123.1
## - `JobRole.Manufacturing Director`     1   2047.1 2123.1
## + `Department.Research & Development`  1   2043.2 2123.2
## + Department.Sales                     1   2043.2 2123.2
## + Education.Bachelor                   1   2043.3 2123.3
## + JobSatisfaction.Medium               1   2043.3 2123.3
## + JobSatisfaction.High                 1   2043.3 2123.3
## + DistanceFromHome                     1   2043.3 2123.3
## + JobRole.Manager                      1   2043.3 2123.3
## + `JobRole.Human Resources`            1   2043.3 2123.3
## + EducationField.Other                 1   2043.3 2123.3
## + `EducationField.Technical Degree`    1   2043.3 2123.3
## + JobSatisfaction.NA                   1   2043.3 2123.3
## - Education.Doctor                     1   2048.2 2124.2
## - `BusinessTravel.Non-Travel`          1   2048.4 2124.4
## - `Department.Human Resources`         1   2048.9 2124.9
## - `JobRole.Research Scientist`         1   2050.2 2126.2
## - `JobRole.Research Director`          1   2050.7 2126.7
## - WorkLifeBalance.Bad                  1   2051.8 2127.8
## - TrainingTimesLastYear                1   2053.1 2129.1
## - Age                                  1   2053.3 2129.3
## - `JobRole.Sales Executive`            1   2054.7 2130.7
## - JobSatisfaction.Low                  1   2054.9 2130.9
## - NumCompaniesWorked                   1   2065.2 2141.2
## - JobSatisfaction.VeryHigh             1   2066.8 2142.8
## - TotalWorkingYears                    1   2071.5 2147.5
## - YearsWithCurrManager                 1   2080.7 2156.7
## - EnvironmentSatisfaction              1   2081.3 2157.3
## - BusinessTravel.Travel_Frequently     1   2086.3 2162.3
## - YearsSinceLastPromotion              1   2094.5 2170.5
## - MaritalStatus.Divorced               1   2094.6 2170.6
## - MaritalStatus.Married                1   2102.4 2178.4
## - OfficeAvgduration                    1   2167.0 2243.0
## 
## Step:  AIC=2119.92
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Marketing + 
##     EducationField.Medical + Gender.Female + JobLevel + `JobRole.Laboratory Technician` + 
##     `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - EducationField.Marketing             1   2044.6 2118.6
## - MonthlyIncome                        1   2045.0 2119.0
## - Gender.Female                        1   2045.1 2119.1
## - JobLevel                             1   2045.1 2119.1
## - StockOptionLevel                     1   2045.3 2119.3
## - YearsAtCompany                       1   2045.5 2119.5
## - Education.College                    1   2045.7 2119.7
## <none>                                     2043.9 2119.9
## - JobInvolvement.High                  1   2046.0 2120.0
## - PercentSalaryHike                    1   2046.1 2120.1
## - WorkLifeBalance.Best                 1   2046.1 2120.1
## - JobInvolvement.Low                   1   2046.3 2120.3
## - EducationField.Medical               1   2046.6 2120.6
## - `EducationField.Life Sciences`       1   2046.7 2120.7
## - `JobRole.Laboratory Technician`      1   2047.0 2121.0
## - `EducationField.Human Resources`     1   2047.2 2121.2
## + `JobRole.Sales Representative`       1   2043.2 2121.2
## + WorkLifeBalance.NA                   1   2043.3 2121.3
## + WorkLifeBalance.Better               1   2043.3 2121.3
## + PerformanceRating.Excellent          1   2043.4 2121.4
## + PerformanceRating.Outstanding        1   2043.4 2121.4
## + `JobRole.Healthcare Representative`  1   2043.5 2121.5
## + JobInvolvement.Medium                1   2043.5 2121.5
## + JobInvolvement.VeryHigh              1   2043.5 2121.5
## + Education.Master                     1   2043.6 2121.6
## - `JobRole.Manufacturing Director`     1   2047.6 2121.6
## + Education.BelowCollege               1   2043.6 2121.6
## + `Department.Research & Development`  1   2043.8 2121.8
## + Department.Sales                     1   2043.8 2121.8
## + Education.Bachelor                   1   2043.9 2121.9
## + JobSatisfaction.Medium               1   2043.9 2121.9
## + JobSatisfaction.High                 1   2043.9 2121.9
## + DistanceFromHome                     1   2043.9 2121.9
## + JobRole.Manager                      1   2043.9 2121.9
## + EducationField.Other                 1   2043.9 2121.9
## + `EducationField.Technical Degree`    1   2043.9 2121.9
## + `JobRole.Human Resources`            1   2043.9 2121.9
## + JobSatisfaction.NA                   1   2043.9 2121.9
## - Education.Doctor                     1   2048.7 2122.7
## - `BusinessTravel.Non-Travel`          1   2048.9 2122.9
## - `Department.Human Resources`         1   2049.5 2123.5
## - `JobRole.Research Scientist`         1   2050.8 2124.8
## - `JobRole.Research Director`          1   2051.4 2125.4
## - TrainingTimesLastYear                1   2053.7 2127.7
## - Age                                  1   2054.0 2128.0
## - WorkLifeBalance.Good                 1   2054.4 2128.4
## - `JobRole.Sales Executive`            1   2055.3 2129.3
## - JobSatisfaction.Low                  1   2055.4 2129.4
## - NumCompaniesWorked                   1   2065.7 2139.7
## - JobSatisfaction.VeryHigh             1   2067.5 2141.5
## - TotalWorkingYears                    1   2072.0 2146.0
## - YearsWithCurrManager                 1   2081.3 2155.3
## - EnvironmentSatisfaction              1   2081.7 2155.7
## - WorkLifeBalance.Bad                  1   2083.8 2157.8
## - BusinessTravel.Travel_Frequently     1   2086.8 2160.8
## - MaritalStatus.Divorced               1   2094.9 2168.9
## - YearsSinceLastPromotion              1   2095.1 2169.1
## - MaritalStatus.Married                1   2102.9 2176.9
## - OfficeAvgduration                    1   2168.4 2242.4
## 
## Step:  AIC=2118.58
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Medical + 
##     Gender.Female + JobLevel + `JobRole.Laboratory Technician` + 
##     `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + MonthlyIncome + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - JobLevel                             1   2045.7 2117.7
## - Gender.Female                        1   2045.8 2117.8
## - MonthlyIncome                        1   2045.8 2117.8
## - StockOptionLevel                     1   2046.0 2118.0
## - YearsAtCompany                       1   2046.2 2118.2
## - Education.College                    1   2046.3 2118.3
## <none>                                     2044.6 2118.6
## - EducationField.Medical               1   2046.6 2118.6
## - WorkLifeBalance.Best                 1   2046.7 2118.7
## - `EducationField.Life Sciences`       1   2046.7 2118.7
## - PercentSalaryHike                    1   2046.8 2118.8
## - JobInvolvement.High                  1   2046.8 2118.8
## - JobInvolvement.Low                   1   2046.9 2118.9
## - `EducationField.Human Resources`     1   2047.4 2119.4
## + `JobRole.Sales Representative`       1   2043.8 2119.8
## - `JobRole.Laboratory Technician`      1   2047.9 2119.9
## + EducationField.Marketing             1   2043.9 2119.9
## + WorkLifeBalance.Better               1   2044.0 2120.0
## + WorkLifeBalance.NA                   1   2044.0 2120.0
## + PerformanceRating.Excellent          1   2044.0 2120.0
## + PerformanceRating.Outstanding        1   2044.0 2120.0
## + `JobRole.Healthcare Representative`  1   2044.1 2120.1
## + JobInvolvement.Medium                1   2044.2 2120.2
## + JobInvolvement.VeryHigh              1   2044.2 2120.2
## + Education.Master                     1   2044.2 2120.2
## + `EducationField.Technical Degree`    1   2044.2 2120.2
## + Education.BelowCollege               1   2044.3 2120.3
## - `JobRole.Manufacturing Director`     1   2048.3 2120.3
## + EducationField.Other                 1   2044.5 2120.5
## + Education.Bachelor                   1   2044.5 2120.5
## + JobSatisfaction.Medium               1   2044.5 2120.6
## + JobSatisfaction.High                 1   2044.5 2120.6
## + DistanceFromHome                     1   2044.6 2120.6
## + JobRole.Manager                      1   2044.6 2120.6
## + `JobRole.Human Resources`            1   2044.6 2120.6
## + JobSatisfaction.NA                   1   2044.6 2120.6
## + `Department.Research & Development`  1   2044.6 2120.6
## + Department.Sales                     1   2044.6 2120.6
## - Education.Doctor                     1   2049.5 2121.5
## - `BusinessTravel.Non-Travel`          1   2049.8 2121.8
## - `Department.Human Resources`         1   2050.0 2122.0
## - `JobRole.Research Scientist`         1   2051.9 2123.9
## - `JobRole.Research Director`          1   2052.2 2124.2
## - TrainingTimesLastYear                1   2054.2 2126.2
## - WorkLifeBalance.Good                 1   2054.9 2126.9
## - Age                                  1   2055.1 2127.1
## - JobSatisfaction.Low                  1   2056.2 2128.2
## - `JobRole.Sales Executive`            1   2056.3 2128.3
## - NumCompaniesWorked                   1   2066.5 2138.5
## - JobSatisfaction.VeryHigh             1   2067.8 2139.8
## - TotalWorkingYears                    1   2072.6 2144.6
## - YearsWithCurrManager                 1   2082.4 2154.4
## - EnvironmentSatisfaction              1   2083.1 2155.1
## - WorkLifeBalance.Bad                  1   2084.6 2156.6
## - BusinessTravel.Travel_Frequently     1   2087.8 2159.8
## - MaritalStatus.Divorced               1   2095.2 2167.2
## - YearsSinceLastPromotion              1   2096.1 2168.1
## - MaritalStatus.Married                1   2103.9 2175.9
## - OfficeAvgduration                    1   2169.4 2241.4
## 
## Step:  AIC=2117.7
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Medical + 
##     Gender.Female + `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - Gender.Female                        1   2047.0 2117.0
## - MonthlyIncome                        1   2047.0 2117.0
## - StockOptionLevel                     1   2047.0 2117.0
## - YearsAtCompany                       1   2047.3 2117.3
## - Education.College                    1   2047.4 2117.4
## <none>                                     2045.7 2117.7
## - WorkLifeBalance.Best                 1   2047.7 2117.7
## - PercentSalaryHike                    1   2047.8 2117.8
## - `EducationField.Life Sciences`       1   2047.8 2117.8
## - EducationField.Medical               1   2047.9 2117.9
## - JobInvolvement.High                  1   2047.9 2117.9
## - JobInvolvement.Low                   1   2048.0 2118.0
## + JobLevel                             1   2044.6 2118.6
## - `EducationField.Human Resources`     1   2048.8 2118.8
## + `JobRole.Sales Representative`       1   2045.0 2119.0
## + EducationField.Marketing             1   2045.1 2119.1
## + WorkLifeBalance.Better               1   2045.1 2119.1
## + WorkLifeBalance.NA                   1   2045.1 2119.1
## + PerformanceRating.Excellent          1   2045.1 2119.1
## + PerformanceRating.Outstanding        1   2045.1 2119.1
## - `JobRole.Laboratory Technician`      1   2049.1 2119.1
## + JobInvolvement.Medium                1   2045.2 2119.2
## + JobInvolvement.VeryHigh              1   2045.2 2119.2
## + Education.BelowCollege               1   2045.3 2119.3
## + `JobRole.Healthcare Representative`  1   2045.3 2119.3
## + Education.Master                     1   2045.3 2119.3
## + `EducationField.Technical Degree`    1   2045.4 2119.4
## - `JobRole.Manufacturing Director`     1   2049.4 2119.4
## + EducationField.Other                 1   2045.6 2119.6
## + Education.Bachelor                   1   2045.7 2119.7
## + JobSatisfaction.Medium               1   2045.7 2119.7
## + JobSatisfaction.High                 1   2045.7 2119.7
## + JobRole.Manager                      1   2045.7 2119.7
## + DistanceFromHome                     1   2045.7 2119.7
## + `Department.Research & Development`  1   2045.7 2119.7
## + Department.Sales                     1   2045.7 2119.7
## + JobSatisfaction.NA                   1   2045.7 2119.7
## + `JobRole.Human Resources`            1   2045.7 2119.7
## - Education.Doctor                     1   2050.6 2120.6
## - `Department.Human Resources`         1   2050.8 2120.8
## - `BusinessTravel.Non-Travel`          1   2050.8 2120.8
## - `JobRole.Research Director`          1   2053.0 2123.0
## - `JobRole.Research Scientist`         1   2053.2 2123.2
## - TrainingTimesLastYear                1   2055.0 2125.0
## - WorkLifeBalance.Good                 1   2056.0 2126.0
## - Age                                  1   2056.6 2126.6
## - JobSatisfaction.Low                  1   2057.3 2127.3
## - `JobRole.Sales Executive`            1   2057.6 2127.6
## - NumCompaniesWorked                   1   2067.8 2137.8
## - JobSatisfaction.VeryHigh             1   2068.7 2138.7
## - TotalWorkingYears                    1   2073.3 2143.3
## - YearsWithCurrManager                 1   2083.8 2153.8
## - EnvironmentSatisfaction              1   2083.9 2153.9
## - WorkLifeBalance.Bad                  1   2085.3 2155.3
## - BusinessTravel.Travel_Frequently     1   2090.2 2160.2
## - MaritalStatus.Divorced               1   2096.9 2166.9
## - YearsSinceLastPromotion              1   2097.5 2167.5
## - MaritalStatus.Married                1   2105.5 2175.5
## - OfficeAvgduration                    1   2170.0 2240.0
## 
## Step:  AIC=2116.96
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Medical + 
##     `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     MonthlyIncome + NumCompaniesWorked + PercentSalaryHike + 
##     StockOptionLevel + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsAtCompany + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - MonthlyIncome                        1   2048.2 2116.2
## - StockOptionLevel                     1   2048.3 2116.3
## - YearsAtCompany                       1   2048.6 2116.6
## - Education.College                    1   2048.7 2116.7
## <none>                                     2047.0 2117.0
## - WorkLifeBalance.Best                 1   2049.0 2117.0
## - `EducationField.Life Sciences`       1   2049.1 2117.1
## - JobInvolvement.High                  1   2049.1 2117.1
## - JobInvolvement.Low                   1   2049.1 2117.1
## - EducationField.Medical               1   2049.1 2117.1
## - PercentSalaryHike                    1   2049.2 2117.2
## + Gender.Female                        1   2045.7 2117.7
## + Gender.Male                          1   2045.7 2117.7
## + JobLevel                             1   2045.8 2117.8
## - `EducationField.Human Resources`     1   2050.2 2118.2
## + `JobRole.Sales Representative`       1   2046.3 2118.3
## + EducationField.Marketing             1   2046.4 2118.4
## + WorkLifeBalance.Better               1   2046.4 2118.4
## + WorkLifeBalance.NA                   1   2046.4 2118.4
## + PerformanceRating.Excellent          1   2046.4 2118.4
## + PerformanceRating.Outstanding        1   2046.4 2118.4
## - `JobRole.Laboratory Technician`      1   2050.4 2118.4
## + JobInvolvement.Medium                1   2046.5 2118.5
## + JobInvolvement.VeryHigh              1   2046.5 2118.5
## + `JobRole.Healthcare Representative`  1   2046.5 2118.5
## + Education.BelowCollege               1   2046.6 2118.6
## + Education.Master                     1   2046.6 2118.6
## + `EducationField.Technical Degree`    1   2046.7 2118.7
## - `JobRole.Manufacturing Director`     1   2050.7 2118.7
## + EducationField.Other                 1   2046.8 2118.8
## + Education.Bachelor                   1   2046.9 2118.9
## + DistanceFromHome                     1   2046.9 2118.9
## + JobSatisfaction.Medium               1   2047.0 2118.9
## + JobSatisfaction.High                 1   2047.0 2118.9
## + `JobRole.Human Resources`            1   2047.0 2119.0
## + JobRole.Manager                      1   2047.0 2119.0
## + JobSatisfaction.NA                   1   2047.0 2119.0
## + `Department.Research & Development`  1   2047.0 2119.0
## + Department.Sales                     1   2047.0 2119.0
## - `BusinessTravel.Non-Travel`          1   2051.8 2119.8
## - `Department.Human Resources`         1   2051.9 2119.9
## - Education.Doctor                     1   2052.0 2120.0
## - `JobRole.Research Director`          1   2054.4 2122.4
## - `JobRole.Research Scientist`         1   2054.8 2122.8
## - TrainingTimesLastYear                1   2056.4 2124.4
## - WorkLifeBalance.Good                 1   2057.6 2125.6
## - Age                                  1   2058.2 2126.2
## - JobSatisfaction.Low                  1   2058.5 2126.5
## - `JobRole.Sales Executive`            1   2059.1 2127.1
## - NumCompaniesWorked                   1   2068.5 2136.5
## - JobSatisfaction.VeryHigh             1   2070.1 2138.1
## - TotalWorkingYears                    1   2074.6 2142.6
## - YearsWithCurrManager                 1   2085.2 2153.2
## - EnvironmentSatisfaction              1   2085.7 2153.7
## - WorkLifeBalance.Bad                  1   2086.6 2154.6
## - BusinessTravel.Travel_Frequently     1   2091.2 2159.2
## - MaritalStatus.Divorced               1   2097.6 2165.6
## - YearsSinceLastPromotion              1   2098.3 2166.3
## - MaritalStatus.Married                1   2106.7 2174.7
## - OfficeAvgduration                    1   2171.6 2239.6
## 
## Step:  AIC=2116.24
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Medical + 
##     `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     NumCompaniesWorked + PercentSalaryHike + StockOptionLevel + 
##     TotalWorkingYears + TrainingTimesLastYear + YearsAtCompany + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - StockOptionLevel                     1   2049.8 2115.8
## - YearsAtCompany                       1   2049.9 2115.9
## - Education.College                    1   2050.0 2116.0
## - WorkLifeBalance.Best                 1   2050.2 2116.2
## <none>                                     2048.2 2116.2
## - `EducationField.Life Sciences`       1   2050.3 2116.3
## - EducationField.Medical               1   2050.3 2116.3
## - JobInvolvement.Low                   1   2050.4 2116.4
## - JobInvolvement.High                  1   2050.6 2116.6
## - PercentSalaryHike                    1   2050.6 2116.6
## + JobLevel                             1   2046.9 2116.9
## + MonthlyIncome                        1   2047.0 2117.0
## + Gender.Female                        1   2047.0 2117.0
## + Gender.Male                          1   2047.0 2117.0
## - `EducationField.Human Resources`     1   2051.4 2117.4
## - `JobRole.Laboratory Technician`      1   2051.6 2117.6
## + `JobRole.Sales Representative`       1   2047.6 2117.6
## + EducationField.Marketing             1   2047.6 2117.6
## + WorkLifeBalance.Better               1   2047.7 2117.7
## + WorkLifeBalance.NA                   1   2047.7 2117.7
## + PerformanceRating.Excellent          1   2047.7 2117.7
## + PerformanceRating.Outstanding        1   2047.7 2117.7
## + Education.BelowCollege               1   2047.8 2117.8
## + `JobRole.Healthcare Representative`  1   2047.8 2117.8
## + JobInvolvement.Medium                1   2047.8 2117.8
## + JobInvolvement.VeryHigh              1   2047.8 2117.8
## + Education.Master                     1   2047.9 2117.9
## + `EducationField.Technical Degree`    1   2048.0 2118.0
## + EducationField.Other                 1   2048.1 2118.1
## - `JobRole.Manufacturing Director`     1   2052.2 2118.2
## + DistanceFromHome                     1   2048.2 2118.2
## + Education.Bachelor                   1   2048.2 2118.2
## + `JobRole.Human Resources`            1   2048.2 2118.2
## + JobRole.Manager                      1   2048.2 2118.2
## + JobSatisfaction.NA                   1   2048.2 2118.2
## + JobSatisfaction.Medium               1   2048.2 2118.2
## + JobSatisfaction.High                 1   2048.2 2118.2
## + `Department.Research & Development`  1   2048.2 2118.2
## + Department.Sales                     1   2048.2 2118.2
## - Education.Doctor                     1   2053.3 2119.3
## - `BusinessTravel.Non-Travel`          1   2053.4 2119.4
## - `Department.Human Resources`         1   2053.4 2119.4
## - `JobRole.Research Director`          1   2055.4 2121.4
## - `JobRole.Research Scientist`         1   2055.9 2121.9
## - TrainingTimesLastYear                1   2057.7 2123.7
## - Age                                  1   2059.0 2125.0
## - WorkLifeBalance.Good                 1   2059.1 2125.1
## - JobSatisfaction.Low                  1   2059.8 2125.8
## - `JobRole.Sales Executive`            1   2060.1 2126.1
## - NumCompaniesWorked                   1   2070.2 2136.2
## - JobSatisfaction.VeryHigh             1   2071.3 2137.3
## - TotalWorkingYears                    1   2076.2 2142.2
## - YearsWithCurrManager                 1   2086.2 2152.2
## - EnvironmentSatisfaction              1   2086.9 2152.9
## - WorkLifeBalance.Bad                  1   2087.1 2153.1
## - BusinessTravel.Travel_Frequently     1   2093.2 2159.2
## - YearsSinceLastPromotion              1   2098.7 2164.7
## - MaritalStatus.Divorced               1   2100.4 2166.4
## - MaritalStatus.Married                1   2109.7 2175.7
## - OfficeAvgduration                    1   2172.4 2238.4
## 
## Step:  AIC=2115.75
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Medical + 
##     `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     NumCompaniesWorked + PercentSalaryHike + TotalWorkingYears + 
##     TrainingTimesLastYear + YearsAtCompany + YearsSinceLastPromotion + 
##     YearsWithCurrManager + EnvironmentSatisfaction + JobSatisfaction.Low + 
##     JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##     WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##     OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - YearsAtCompany                       1   2051.3 2115.3
## - Education.College                    1   2051.5 2115.5
## - EducationField.Medical               1   2051.5 2115.5
## - WorkLifeBalance.Best                 1   2051.7 2115.7
## <none>                                     2049.8 2115.8
## - `EducationField.Life Sciences`       1   2051.8 2115.8
## - JobInvolvement.High                  1   2052.0 2116.0
## - JobInvolvement.Low                   1   2052.1 2116.1
## - PercentSalaryHike                    1   2052.2 2116.2
## + StockOptionLevel                     1   2048.2 2116.2
## + MonthlyIncome                        1   2048.3 2116.3
## + JobLevel                             1   2048.4 2116.4
## + Gender.Female                        1   2048.5 2116.5
## + Gender.Male                          1   2048.5 2116.5
## - `JobRole.Laboratory Technician`      1   2052.7 2116.7
## - `EducationField.Human Resources`     1   2052.9 2116.9
## + `JobRole.Sales Representative`       1   2049.1 2117.1
## + EducationField.Marketing             1   2049.1 2117.1
## + WorkLifeBalance.Better               1   2049.2 2117.2
## + WorkLifeBalance.NA                   1   2049.2 2117.2
## + Education.BelowCollege               1   2049.3 2117.3
## + PerformanceRating.Excellent          1   2049.3 2117.3
## + PerformanceRating.Outstanding        1   2049.3 2117.3
## + `JobRole.Healthcare Representative`  1   2049.3 2117.3
## + JobInvolvement.Medium                1   2049.3 2117.3
## + JobInvolvement.VeryHigh              1   2049.3 2117.3
## + Education.Master                     1   2049.4 2117.4
## + `EducationField.Technical Degree`    1   2049.5 2117.5
## + EducationField.Other                 1   2049.6 2117.6
## + DistanceFromHome                     1   2049.7 2117.7
## + `JobRole.Human Resources`            1   2049.7 2117.7
## + Education.Bachelor                   1   2049.7 2117.7
## + `Department.Research & Development`  1   2049.7 2117.7
## + Department.Sales                     1   2049.7 2117.7
## + JobSatisfaction.NA                   1   2049.8 2117.8
## + JobSatisfaction.Medium               1   2049.8 2117.8
## + JobSatisfaction.High                 1   2049.8 2117.8
## + JobRole.Manager                      1   2049.8 2117.8
## - `JobRole.Manufacturing Director`     1   2053.9 2117.9
## - `BusinessTravel.Non-Travel`          1   2054.8 2118.8
## - `Department.Human Resources`         1   2054.8 2118.8
## - Education.Doctor                     1   2054.9 2118.9
## - `JobRole.Research Director`          1   2056.8 2120.8
## - `JobRole.Research Scientist`         1   2056.9 2120.9
## - TrainingTimesLastYear                1   2058.7 2122.7
## - Age                                  1   2060.1 2124.1
## - WorkLifeBalance.Good                 1   2060.8 2124.8
## - `JobRole.Sales Executive`            1   2060.8 2124.8
## - JobSatisfaction.Low                  1   2061.9 2125.9
## - NumCompaniesWorked                   1   2071.5 2135.5
## - JobSatisfaction.VeryHigh             1   2072.1 2136.1
## - TotalWorkingYears                    1   2078.0 2142.0
## - YearsWithCurrManager                 1   2087.1 2151.1
## - WorkLifeBalance.Bad                  1   2088.1 2152.1
## - EnvironmentSatisfaction              1   2088.9 2152.9
## - BusinessTravel.Travel_Frequently     1   2095.6 2159.6
## - YearsSinceLastPromotion              1   2100.7 2164.7
## - MaritalStatus.Divorced               1   2101.4 2165.4
## - MaritalStatus.Married                1   2110.6 2174.6
## - OfficeAvgduration                    1   2175.3 2239.3
## 
## Step:  AIC=2115.27
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + EducationField.Medical + 
##     `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     NumCompaniesWorked + PercentSalaryHike + TotalWorkingYears + 
##     TrainingTimesLastYear + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - EducationField.Medical               1   2052.9 2114.9
## - Education.College                    1   2053.1 2115.1
## - `EducationField.Life Sciences`       1   2053.2 2115.2
## - WorkLifeBalance.Best                 1   2053.2 2115.2
## <none>                                     2051.3 2115.3
## - JobInvolvement.High                  1   2053.4 2115.4
## - PercentSalaryHike                    1   2053.7 2115.7
## + YearsAtCompany                       1   2049.8 2115.8
## - JobInvolvement.Low                   1   2053.8 2115.8
## + MonthlyIncome                        1   2049.8 2115.8
## + JobLevel                             1   2049.9 2115.9
## + StockOptionLevel                     1   2049.9 2115.9
## + Gender.Female                        1   2050.0 2116.0
## + Gender.Male                          1   2050.0 2116.0
## - `JobRole.Laboratory Technician`      1   2054.2 2116.2
## - `EducationField.Human Resources`     1   2054.4 2116.4
## + `JobRole.Sales Representative`       1   2050.6 2116.6
## + EducationField.Marketing             1   2050.7 2116.7
## + WorkLifeBalance.Better               1   2050.7 2116.7
## + WorkLifeBalance.NA                   1   2050.7 2116.7
## + Education.BelowCollege               1   2050.8 2116.8
## + JobInvolvement.Medium                1   2050.8 2116.8
## + JobInvolvement.VeryHigh              1   2050.8 2116.8
## + `JobRole.Healthcare Representative`  1   2050.9 2116.9
## + PerformanceRating.Excellent          1   2050.9 2116.9
## + PerformanceRating.Outstanding        1   2050.9 2116.9
## + Education.Master                     1   2050.9 2116.9
## + `EducationField.Technical Degree`    1   2051.0 2117.0
## + EducationField.Other                 1   2051.2 2117.2
## + Education.Bachelor                   1   2051.2 2117.2
## + DistanceFromHome                     1   2051.3 2117.3
## + `JobRole.Human Resources`            1   2051.3 2117.3
## + `Department.Research & Development`  1   2051.3 2117.3
## + Department.Sales                     1   2051.3 2117.3
## + JobSatisfaction.NA                   1   2051.3 2117.3
## + JobSatisfaction.High                 1   2051.3 2117.3
## + JobSatisfaction.Medium               1   2051.3 2117.3
## + JobRole.Manager                      1   2051.3 2117.3
## - `JobRole.Manufacturing Director`     1   2055.5 2117.5
## - `BusinessTravel.Non-Travel`          1   2056.2 2118.2
## - `Department.Human Resources`         1   2056.4 2118.4
## - Education.Doctor                     1   2056.6 2118.6
## - `JobRole.Research Scientist`         1   2058.1 2120.1
## - `JobRole.Research Director`          1   2058.2 2120.2
## - TrainingTimesLastYear                1   2060.3 2122.3
## - `JobRole.Sales Executive`            1   2061.9 2123.9
## - WorkLifeBalance.Good                 1   2062.0 2124.0
## - Age                                  1   2062.5 2124.5
## - JobSatisfaction.Low                  1   2062.9 2124.9
## - NumCompaniesWorked                   1   2071.5 2133.5
## - JobSatisfaction.VeryHigh             1   2073.3 2135.3
## - TotalWorkingYears                    1   2079.8 2141.8
## - WorkLifeBalance.Bad                  1   2089.2 2151.2
## - EnvironmentSatisfaction              1   2089.9 2151.9
## - YearsWithCurrManager                 1   2095.5 2157.5
## - BusinessTravel.Travel_Frequently     1   2097.2 2159.2
## - MaritalStatus.Divorced               1   2101.7 2163.7
## - MaritalStatus.Married                1   2111.8 2173.8
## - YearsSinceLastPromotion              1   2116.7 2178.7
## - OfficeAvgduration                    1   2176.3 2238.3
## 
## Step:  AIC=2114.88
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `EducationField.Life Sciences` + `JobRole.Laboratory Technician` + 
##     `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + NumCompaniesWorked + 
##     PercentSalaryHike + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - `EducationField.Life Sciences`       1   2053.5 2113.5
## - Education.College                    1   2054.8 2114.8
## <none>                                     2052.9 2114.9
## - JobInvolvement.High                  1   2055.0 2115.0
## - WorkLifeBalance.Best                 1   2055.1 2115.1
## - `EducationField.Human Resources`     1   2055.2 2115.2
## + EducationField.Medical               1   2051.3 2115.3
## + JobLevel                             1   2051.4 2115.4
## - JobInvolvement.Low                   1   2055.4 2115.4
## - PercentSalaryHike                    1   2055.5 2115.5
## + YearsAtCompany                       1   2051.5 2115.5
## + MonthlyIncome                        1   2051.6 2115.6
## + Gender.Female                        1   2051.6 2115.6
## + Gender.Male                          1   2051.6 2115.6
## + `EducationField.Technical Degree`    1   2051.8 2115.8
## + StockOptionLevel                     1   2051.8 2115.8
## - `JobRole.Laboratory Technician`      1   2055.8 2115.8
## + EducationField.Other                 1   2052.2 2116.2
## + `JobRole.Sales Representative`       1   2052.3 2116.3
## + WorkLifeBalance.Better               1   2052.3 2116.3
## + WorkLifeBalance.NA                   1   2052.3 2116.3
## + Education.BelowCollege               1   2052.4 2116.4
## + `JobRole.Healthcare Representative`  1   2052.5 2116.5
## + PerformanceRating.Excellent          1   2052.5 2116.5
## + PerformanceRating.Outstanding        1   2052.5 2116.5
## + JobInvolvement.Medium                1   2052.5 2116.5
## + JobInvolvement.VeryHigh              1   2052.5 2116.5
## + Education.Master                     1   2052.5 2116.5
## + `Department.Research & Development`  1   2052.6 2116.6
## + Department.Sales                     1   2052.6 2116.6
## + DistanceFromHome                     1   2052.9 2116.9
## + Education.Bachelor                   1   2052.9 2116.9
## + EducationField.Marketing             1   2052.9 2116.9
## + `JobRole.Human Resources`            1   2052.9 2116.9
## + JobSatisfaction.NA                   1   2052.9 2116.9
## + JobRole.Manager                      1   2052.9 2116.9
## + JobSatisfaction.High                 1   2052.9 2116.9
## + JobSatisfaction.Medium               1   2052.9 2116.9
## - `JobRole.Manufacturing Director`     1   2057.0 2117.0
## - `BusinessTravel.Non-Travel`          1   2057.7 2117.7
## - Education.Doctor                     1   2058.0 2118.0
## - `Department.Human Resources`         1   2058.2 2118.2
## - `JobRole.Research Director`          1   2059.6 2119.6
## - `JobRole.Research Scientist`         1   2060.0 2120.0
## - TrainingTimesLastYear                1   2061.7 2121.7
## - WorkLifeBalance.Good                 1   2063.5 2123.5
## - `JobRole.Sales Executive`            1   2063.6 2123.6
## - Age                                  1   2064.1 2124.1
## - JobSatisfaction.Low                  1   2064.3 2124.3
## - NumCompaniesWorked                   1   2072.7 2132.7
## - JobSatisfaction.VeryHigh             1   2075.4 2135.4
## - TotalWorkingYears                    1   2081.5 2141.5
## - EnvironmentSatisfaction              1   2090.9 2150.9
## - WorkLifeBalance.Bad                  1   2091.1 2151.1
## - YearsWithCurrManager                 1   2097.0 2157.0
## - BusinessTravel.Travel_Frequently     1   2099.3 2159.3
## - MaritalStatus.Divorced               1   2103.1 2163.1
## - MaritalStatus.Married                1   2113.8 2173.8
## - YearsSinceLastPromotion              1   2118.2 2178.2
## - OfficeAvgduration                    1   2178.2 2238.2
## 
## Step:  AIC=2113.49
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.College + Education.Doctor + `EducationField.Human Resources` + 
##     `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##     `JobRole.Research Director` + `JobRole.Research Scientist` + 
##     `JobRole.Sales Executive` + MaritalStatus.Divorced + MaritalStatus.Married + 
##     NumCompaniesWorked + PercentSalaryHike + TotalWorkingYears + 
##     TrainingTimesLastYear + YearsSinceLastPromotion + YearsWithCurrManager + 
##     EnvironmentSatisfaction + JobSatisfaction.Low + JobSatisfaction.VeryHigh + 
##     WorkLifeBalance.Bad + WorkLifeBalance.Best + WorkLifeBalance.Good + 
##     JobInvolvement.High + JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## - Education.College                    1   2055.4 2113.4
## <none>                                     2053.5 2113.5
## - JobInvolvement.High                  1   2055.5 2113.5
## - `EducationField.Human Resources`     1   2055.7 2113.7
## - WorkLifeBalance.Best                 1   2055.7 2113.7
## + `EducationField.Technical Degree`    1   2052.0 2114.0
## - JobInvolvement.Low                   1   2056.0 2114.0
## + JobLevel                             1   2052.1 2114.1
## - PercentSalaryHike                    1   2056.1 2114.1
## + YearsAtCompany                       1   2052.2 2114.2
## + MonthlyIncome                        1   2052.2 2114.2
## + Gender.Female                        1   2052.2 2114.2
## + Gender.Male                          1   2052.2 2114.2
## + StockOptionLevel                     1   2052.3 2114.3
## - `JobRole.Laboratory Technician`      1   2056.3 2114.3
## + EducationField.Other                 1   2052.6 2114.6
## + `JobRole.Sales Representative`       1   2052.9 2114.9
## + `EducationField.Life Sciences`       1   2052.9 2114.9
## + WorkLifeBalance.Better               1   2052.9 2114.9
## + WorkLifeBalance.NA                   1   2052.9 2114.9
## + JobInvolvement.Medium                1   2053.1 2115.1
## + JobInvolvement.VeryHigh              1   2053.1 2115.1
## + Education.BelowCollege               1   2053.1 2115.1
## + PerformanceRating.Excellent          1   2053.1 2115.1
## + PerformanceRating.Outstanding        1   2053.1 2115.1
## + `JobRole.Healthcare Representative`  1   2053.1 2115.1
## + `Department.Research & Development`  1   2053.1 2115.1
## + Department.Sales                     1   2053.1 2115.1
## + Education.Master                     1   2053.2 2115.2
## + EducationField.Medical               1   2053.2 2115.2
## + EducationField.Marketing             1   2053.4 2115.4
## + Education.Bachelor                   1   2053.5 2115.5
## + DistanceFromHome                     1   2053.5 2115.5
## + `JobRole.Human Resources`            1   2053.5 2115.5
## + JobSatisfaction.NA                   1   2053.5 2115.5
## + JobSatisfaction.High                 1   2053.5 2115.5
## + JobRole.Manager                      1   2053.5 2115.5
## + JobSatisfaction.Medium               1   2053.5 2115.5
## - `JobRole.Manufacturing Director`     1   2057.5 2115.5
## - `BusinessTravel.Non-Travel`          1   2058.3 2116.3
## - Education.Doctor                     1   2058.6 2116.6
## - `Department.Human Resources`         1   2058.7 2116.7
## - `JobRole.Research Director`          1   2060.1 2118.1
## - `JobRole.Research Scientist`         1   2060.5 2118.5
## - TrainingTimesLastYear                1   2062.1 2120.1
## - `JobRole.Sales Executive`            1   2064.0 2122.0
## - WorkLifeBalance.Good                 1   2064.1 2122.1
## - Age                                  1   2064.8 2122.8
## - JobSatisfaction.Low                  1   2065.3 2123.3
## - NumCompaniesWorked                   1   2073.5 2131.5
## - JobSatisfaction.VeryHigh             1   2075.8 2133.8
## - TotalWorkingYears                    1   2082.1 2140.1
## - EnvironmentSatisfaction              1   2091.2 2149.2
## - WorkLifeBalance.Bad                  1   2091.8 2149.8
## - YearsWithCurrManager                 1   2097.2 2155.2
## - BusinessTravel.Travel_Frequently     1   2099.4 2157.4
## - MaritalStatus.Divorced               1   2105.2 2163.2
## - MaritalStatus.Married                1   2115.3 2173.3
## - YearsSinceLastPromotion              1   2118.4 2176.4
## - OfficeAvgduration                    1   2178.7 2236.7
## 
## Step:  AIC=2113.42
## consolidated_employee_regression_train$Attrition ~ Age + `BusinessTravel.Non-Travel` + 
##     BusinessTravel.Travel_Frequently + `Department.Human Resources` + 
##     Education.Doctor + `EducationField.Human Resources` + `JobRole.Laboratory Technician` + 
##     `JobRole.Manufacturing Director` + `JobRole.Research Director` + 
##     `JobRole.Research Scientist` + `JobRole.Sales Executive` + 
##     MaritalStatus.Divorced + MaritalStatus.Married + NumCompaniesWorked + 
##     PercentSalaryHike + TotalWorkingYears + TrainingTimesLastYear + 
##     YearsSinceLastPromotion + YearsWithCurrManager + EnvironmentSatisfaction + 
##     JobSatisfaction.Low + JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + 
##     WorkLifeBalance.Best + WorkLifeBalance.Good + JobInvolvement.High + 
##     JobInvolvement.Low + OfficeAvgduration
## 
##                                       Df Deviance    AIC
## <none>                                     2055.4 2113.4
## + Education.College                    1   2053.5 2113.5
## - WorkLifeBalance.Best                 1   2057.5 2113.5
## - JobInvolvement.High                  1   2057.8 2113.8
## - `EducationField.Human Resources`     1   2057.9 2113.9
## - JobInvolvement.Low                   1   2058.0 2114.0
## + JobLevel                             1   2054.1 2114.1
## + `EducationField.Technical Degree`    1   2054.1 2114.1
## + YearsAtCompany                       1   2054.1 2114.1
## + MonthlyIncome                        1   2054.1 2114.1
## + StockOptionLevel                     1   2054.2 2114.2
## + Gender.Female                        1   2054.2 2114.2
## + Gender.Male                          1   2054.2 2114.2
## - PercentSalaryHike                    1   2058.2 2114.2
## - `JobRole.Laboratory Technician`      1   2058.4 2114.4
## + EducationField.Other                 1   2054.4 2114.4
## + Education.Master                     1   2054.4 2114.4
## + `EducationField.Life Sciences`       1   2054.8 2114.8
## + WorkLifeBalance.Better               1   2054.9 2114.9
## + WorkLifeBalance.NA                   1   2054.9 2114.9
## + `JobRole.Sales Representative`       1   2054.9 2114.9
## + JobInvolvement.Medium                1   2054.9 2114.9
## + JobInvolvement.VeryHigh              1   2054.9 2114.9
## + `JobRole.Healthcare Representative`  1   2055.0 2115.0
## + PerformanceRating.Excellent          1   2055.1 2115.1
## + PerformanceRating.Outstanding        1   2055.1 2115.1
## + `Department.Research & Development`  1   2055.1 2115.1
## + Department.Sales                     1   2055.1 2115.1
## + EducationField.Medical               1   2055.1 2115.1
## + Education.Bachelor                   1   2055.2 2115.2
## + Education.BelowCollege               1   2055.3 2115.3
## + EducationField.Marketing             1   2055.3 2115.3
## + DistanceFromHome                     1   2055.4 2115.4
## - `JobRole.Manufacturing Director`     1   2059.4 2115.4
## + JobRole.Manager                      1   2055.4 2115.4
## + JobSatisfaction.NA                   1   2055.4 2115.4
## + `JobRole.Human Resources`            1   2055.4 2115.4
## + JobSatisfaction.Medium               1   2055.4 2115.4
## + JobSatisfaction.High                 1   2055.4 2115.4
## - `BusinessTravel.Non-Travel`          1   2060.1 2116.1
## - `Department.Human Resources`         1   2060.4 2116.4
## - Education.Doctor                     1   2061.3 2117.3
## - `JobRole.Research Director`          1   2061.6 2117.6
## - `JobRole.Research Scientist`         1   2062.3 2118.3
## - TrainingTimesLastYear                1   2065.2 2121.2
## - WorkLifeBalance.Good                 1   2066.0 2122.0
## - `JobRole.Sales Executive`            1   2066.3 2122.3
## - Age                                  1   2066.4 2122.4
## - JobSatisfaction.Low                  1   2066.9 2122.9
## - NumCompaniesWorked                   1   2074.9 2130.9
## - JobSatisfaction.VeryHigh             1   2078.7 2134.7
## - TotalWorkingYears                    1   2084.7 2140.7
## - WorkLifeBalance.Bad                  1   2092.8 2148.8
## - EnvironmentSatisfaction              1   2092.8 2148.8
## - YearsWithCurrManager                 1   2100.2 2156.2
## - BusinessTravel.Travel_Frequently     1   2101.2 2157.2
## - MaritalStatus.Divorced               1   2107.9 2163.9
## - MaritalStatus.Married                1   2118.2 2174.2
## - YearsSinceLastPromotion              1   2120.7 2176.7
## - OfficeAvgduration                    1   2180.9 2236.9
## 
## Call:  glm(formula = consolidated_employee_regression_train$Attrition ~ 
##     Age + `BusinessTravel.Non-Travel` + BusinessTravel.Travel_Frequently + 
##         `Department.Human Resources` + Education.Doctor + `EducationField.Human Resources` + 
##         `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##         `JobRole.Research Director` + `JobRole.Research Scientist` + 
##         `JobRole.Sales Executive` + MaritalStatus.Divorced + 
##         MaritalStatus.Married + NumCompaniesWorked + PercentSalaryHike + 
##         TotalWorkingYears + TrainingTimesLastYear + YearsSinceLastPromotion + 
##         YearsWithCurrManager + EnvironmentSatisfaction + JobSatisfaction.Low + 
##         JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##         WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##         OfficeAvgduration, family = binomial(link = "logit"), 
##     data = consolidated_employee_regression_train)
## 
## Coefficients:
##                      (Intercept)                               Age  
##                         -2.74714                          -0.02854  
##      `BusinessTravel.Non-Travel`  BusinessTravel.Travel_Frequently  
##                         -0.47605                           0.90615  
##     `Department.Human Resources`                  Education.Doctor  
##                          0.76016                          -0.81888  
## `EducationField.Human Resources`   `JobRole.Laboratory Technician`  
##                          0.72295                           0.30937  
## `JobRole.Manufacturing Director`       `JobRole.Research Director`  
##                         -0.46996                           0.65161  
##     `JobRole.Research Scientist`         `JobRole.Sales Executive`  
##                          0.44670                           0.54005  
##           MaritalStatus.Divorced             MaritalStatus.Married  
##                         -1.17230                          -0.98434  
##               NumCompaniesWorked                 PercentSalaryHike  
##                          0.10783                           0.02585  
##                TotalWorkingYears             TrainingTimesLastYear  
##                         -0.07342                          -0.14009  
##          YearsSinceLastPromotion              YearsWithCurrManager  
##                          0.19554                          -0.15966  
##          EnvironmentSatisfaction               JobSatisfaction.Low  
##                         -0.31531                           0.48627  
##         JobSatisfaction.VeryHigh               WorkLifeBalance.Bad  
##                         -0.66474                           1.37049  
##             WorkLifeBalance.Best              WorkLifeBalance.Good  
##                          0.27686                           0.44631  
##              JobInvolvement.High                JobInvolvement.Low  
##                         -0.18616                           0.37372  
##                OfficeAvgduration  
##                          0.44872  
## 
## Degrees of Freedom: 3035 Total (i.e. Null);  3007 Residual
##   (35 observations deleted due to missingness)
## Null Deviance:       2674 
## Residual Deviance: 2055  AIC: 2113

Final Regression Model

Here we have taken the model which has lowest AIC value and generated the model object. Coefficients are plotted.

set.seed(3421)
reg_modelstudent_step <- glm(formula = consolidated_employee_regression_train$Attrition ~ 
    Age + `BusinessTravel.Non-Travel` + BusinessTravel.Travel_Frequently + 
        `Department.Human Resources` + Education.Doctor + `EducationField.Human Resources` + 
        `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
        `JobRole.Research Director` + `JobRole.Research Scientist` + 
        `JobRole.Sales Executive` + MaritalStatus.Divorced + 
        MaritalStatus.Married + NumCompaniesWorked + PercentSalaryHike + 
        TotalWorkingYears + TrainingTimesLastYear + YearsSinceLastPromotion + 
        YearsWithCurrManager + EnvironmentSatisfaction + JobSatisfaction.Low + 
        JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
        WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
        OfficeAvgduration, family = binomial(link = "logit"), 
    data = consolidated_employee_regression_train, na.action = na.exclude)

coefficients(reg_modelstudent_step)
##                      (Intercept)                              Age 
##                      -2.74713919                      -0.02853725 
##      `BusinessTravel.Non-Travel` BusinessTravel.Travel_Frequently 
##                      -0.47604790                       0.90615039 
##     `Department.Human Resources`                 Education.Doctor 
##                       0.76015541                      -0.81888491 
## `EducationField.Human Resources`  `JobRole.Laboratory Technician` 
##                       0.72295492                       0.30937130 
## `JobRole.Manufacturing Director`      `JobRole.Research Director` 
##                      -0.46996313                       0.65161036 
##     `JobRole.Research Scientist`        `JobRole.Sales Executive` 
##                       0.44670358                       0.54005491 
##           MaritalStatus.Divorced            MaritalStatus.Married 
##                      -1.17230434                      -0.98434268 
##               NumCompaniesWorked                PercentSalaryHike 
##                       0.10783394                       0.02584616 
##                TotalWorkingYears            TrainingTimesLastYear 
##                      -0.07342178                      -0.14008559 
##          YearsSinceLastPromotion             YearsWithCurrManager 
##                       0.19553746                      -0.15966305 
##          EnvironmentSatisfaction              JobSatisfaction.Low 
##                      -0.31530763                       0.48627434 
##         JobSatisfaction.VeryHigh              WorkLifeBalance.Bad 
##                      -0.66473929                       1.37049437 
##             WorkLifeBalance.Best             WorkLifeBalance.Good 
##                       0.27685921                       0.44631328 
##              JobInvolvement.High               JobInvolvement.Low 
##                      -0.18615635                       0.37371650 
##                OfficeAvgduration 
##                       0.44871987
summary(reg_modelstudent_step)
## 
## Call:
## glm(formula = consolidated_employee_regression_train$Attrition ~ 
##     Age + `BusinessTravel.Non-Travel` + BusinessTravel.Travel_Frequently + 
##         `Department.Human Resources` + Education.Doctor + `EducationField.Human Resources` + 
##         `JobRole.Laboratory Technician` + `JobRole.Manufacturing Director` + 
##         `JobRole.Research Director` + `JobRole.Research Scientist` + 
##         `JobRole.Sales Executive` + MaritalStatus.Divorced + 
##         MaritalStatus.Married + NumCompaniesWorked + PercentSalaryHike + 
##         TotalWorkingYears + TrainingTimesLastYear + YearsSinceLastPromotion + 
##         YearsWithCurrManager + EnvironmentSatisfaction + JobSatisfaction.Low + 
##         JobSatisfaction.VeryHigh + WorkLifeBalance.Bad + WorkLifeBalance.Best + 
##         WorkLifeBalance.Good + JobInvolvement.High + JobInvolvement.Low + 
##         OfficeAvgduration, family = binomial(link = "logit"), 
##     data = consolidated_employee_regression_train, na.action = na.exclude)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.9109  -0.5427  -0.3361  -0.1634   3.8737  
## 
## Coefficients:
##                                   Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                      -2.747139   0.520511  -5.278 1.31e-07 ***
## Age                              -0.028537   0.008767  -3.255 0.001134 ** 
## `BusinessTravel.Non-Travel`      -0.476048   0.229773  -2.072 0.038282 *  
## BusinessTravel.Travel_Frequently  0.906150   0.131998   6.865 6.66e-12 ***
## `Department.Human Resources`      0.760155   0.325931   2.332 0.019687 *  
## Education.Doctor                 -0.818885   0.362578  -2.259 0.023914 *  
## `EducationField.Human Resources`  0.722955   0.465152   1.554 0.120129    
## `JobRole.Laboratory Technician`   0.309371   0.179854   1.720 0.085410 .  
## `JobRole.Manufacturing Director` -0.469963   0.240476  -1.954 0.050665 .  
## `JobRole.Research Director`       0.651610   0.256371   2.542 0.011032 *  
## `JobRole.Research Scientist`      0.446704   0.170501   2.620 0.008795 ** 
## `JobRole.Sales Executive`         0.540055   0.164361   3.286 0.001017 ** 
## MaritalStatus.Divorced           -1.172304   0.170484  -6.876 6.14e-12 ***
## MaritalStatus.Married            -0.984343   0.125746  -7.828 4.96e-15 ***
## NumCompaniesWorked                0.107834   0.024134   4.468 7.89e-06 ***
## PercentSalaryHike                 0.025846   0.015438   1.674 0.094090 .  
## TotalWorkingYears                -0.073422   0.014046  -5.227 1.72e-07 ***
## TrainingTimesLastYear            -0.140086   0.045342  -3.090 0.002005 ** 
## YearsSinceLastPromotion           0.195537   0.023796   8.217  < 2e-16 ***
## YearsWithCurrManager             -0.159663   0.024445  -6.532 6.51e-11 ***
## EnvironmentSatisfaction          -0.315308   0.051905  -6.075 1.24e-09 ***
## JobSatisfaction.Low               0.486274   0.142264   3.418 0.000631 ***
## JobSatisfaction.VeryHigh         -0.664739   0.141182  -4.708 2.50e-06 ***
## WorkLifeBalance.Bad               1.370494   0.214015   6.404 1.52e-10 ***
## WorkLifeBalance.Best              0.276859   0.188542   1.468 0.141990    
## WorkLifeBalance.Good              0.446313   0.136060   3.280 0.001037 ** 
## JobInvolvement.High              -0.186156   0.121249  -1.535 0.124706    
## JobInvolvement.Low                0.373716   0.231029   1.618 0.105745    
## OfficeAvgduration                 0.448720   0.040649  11.039  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 2673.8  on 3035  degrees of freedom
## Residual deviance: 2055.4  on 3007  degrees of freedom
##   (35 observations deleted due to missingness)
## AIC: 2113.4
## 
## Number of Fisher Scoring iterations: 6
coefplot.glm(reg_modelstudent_step,parm = -1)

### Test multicollinearity in the model . As seen below, all X variables in the model have VIF well below 4.

vif(reg_modelstudent_step)
##                              Age      `BusinessTravel.Non-Travel` 
##                         1.807203                         1.050606 
## BusinessTravel.Travel_Frequently     `Department.Human Resources` 
##                         1.079897                         1.933389 
##                 Education.Doctor `EducationField.Human Resources` 
##                         1.039925                         1.922039 
##  `JobRole.Laboratory Technician` `JobRole.Manufacturing Director` 
##                         1.455272                         1.231512 
##      `JobRole.Research Director`     `JobRole.Research Scientist` 
##                         1.218529                         1.516131 
##        `JobRole.Sales Executive`           MaritalStatus.Divorced 
##                         1.597109                         1.198932 
##            MaritalStatus.Married               NumCompaniesWorked 
##                         1.205663                         1.260971 
##                PercentSalaryHike                TotalWorkingYears 
##                         1.031695                         2.516941 
##            TrainingTimesLastYear          YearsSinceLastPromotion 
##                         1.022945                         1.929559 
##             YearsWithCurrManager          EnvironmentSatisfaction 
##                         1.860092                         1.050004 
##              JobSatisfaction.Low         JobSatisfaction.VeryHigh 
##                         1.151907                         1.162394 
##              WorkLifeBalance.Bad             WorkLifeBalance.Best 
##                         1.091912                         1.086528 
##             WorkLifeBalance.Good              JobInvolvement.High 
##                         1.123729                         1.142761 
##               JobInvolvement.Low                OfficeAvgduration 
##                         1.142721                         1.061438

Prediction on test data

Note that thevalidtaion dataframe has some rows with null values and they need to be removed and then used for prediction

row.has.na <- apply(consolidated_employee_regression_val, 1, function(x){any(is.na(x))})
sum(row.has.na)
## [1] 18
consolidated_employee_regression_val_filtered <- consolidated_employee_regression_val[!row.has.na,]

consolidated_employee_regression_val_filtered$AttritionProb <- predict(reg_modelstudent_step, newdata=consolidated_employee_regression_val_filtered, type="response")


# consolidated_employee_regression_val$AttritionProb <- predict(reg_modelstudent_step, newdata=consolidated_employee_regression_val, type="response",na.action = na.exclude)

consolidated_employee_regression_val_filtered$AttritionPredicted <- ifelse(consolidated_employee_regression_val_filtered$AttritionProb  > 0.5,1,0)  ### assigning the probability to value

EmployeeAttrition <- table(actualclass=consolidated_employee_regression_val_filtered$Attrition, predictedclass=consolidated_employee_regression_val_filtered$AttritionPredicted)
confusionMatrix(EmployeeAttrition)
## Confusion Matrix and Statistics
## 
##            predictedclass
## actualclass    0    1
##           0 1076   32
##           1  159   54
##                                           
##                Accuracy : 0.8554          
##                  95% CI : (0.8353, 0.8739)
##     No Information Rate : 0.9349          
##     P-Value [Acc > NIR] : 1               
##                                           
##                   Kappa : 0.2959          
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.8713          
##             Specificity : 0.6279          
##          Pos Pred Value : 0.9711          
##          Neg Pred Value : 0.2535          
##              Prevalence : 0.9349          
##          Detection Rate : 0.8145          
##    Detection Prevalence : 0.8388          
##       Balanced Accuracy : 0.7496          
##                                           
##        'Positive' Class : 0               
## 

Testing the Accuracy of the model

EmployeeAttritionMatrix <- confusionMatrix(EmployeeAttrition)
print(EmployeeAttritionMatrix)
## Confusion Matrix and Statistics
## 
##            predictedclass
## actualclass    0    1
##           0 1076   32
##           1  159   54
##                                           
##                Accuracy : 0.8554          
##                  95% CI : (0.8353, 0.8739)
##     No Information Rate : 0.9349          
##     P-Value [Acc > NIR] : 1               
##                                           
##                   Kappa : 0.2959          
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.8713          
##             Specificity : 0.6279          
##          Pos Pred Value : 0.9711          
##          Neg Pred Value : 0.2535          
##              Prevalence : 0.9349          
##          Detection Rate : 0.8145          
##    Detection Prevalence : 0.8388          
##       Balanced Accuracy : 0.7496          
##                                           
##        'Positive' Class : 0               
## 

Regularisation of Logistic Model

Some of the coefficients are still high and that reduces the risk of model being iverfitting. We will use lasso regression regularisation model here for fine-tuning the coefficients. Important point to note is that we’ll use the function cv.glmnet, which automatically performs a grid search to find the optimal value of lambda.

The glmnet function model.matrix creates the matrix and also converts categorical predictors to appropriate dummy variables.

The plot shows that the log of the optimal value of lambda (i.e. the one that minimises the root mean square error) is approximately -6. The exact value can be viewed by examining the variable lambda_min in the code below. In general though, the objective of regularisation is to balance accuracy and simplicity.

The output coef shows that only those variables that we had determined to be significant on the basis of p-values have non-zero coefficients.The coefficients of all other variables have been set to zero by the algorithm! Lasso has reduced the complexity of the fitting function massively

row.has.na_trn <- apply(consolidated_employee_regression_train, 1, function(x){any(is.na(x))})
sum(row.has.na_trn)
## [1] 35
consolidated_employee_regression_train_filtered <- consolidated_employee_regression_train[!row.has.na_trn,]

#convert training data to matrix format
xInput <- model.matrix(consolidated_employee_regression_train_filtered$Attrition~.,consolidated_employee_regression_train_filtered)
yResponse <- consolidated_employee_regression_train_filtered$Attrition

#perform grid search to find optimal value of lambda #family= binomial => logistic regression, alpha=1 => lasso 

Employeecv.out <- cv.glmnet(xInput,yResponse, alpha=1, family="binomial", type.measure = "class")
#plot result
plot(Employeecv.out)

#min value of lambda
lambda_min <- Employeecv.out$lambda.min
#best value of lambda
lambda_1se <- Employeecv.out$lambda.1se
lambda_1se
## [1] 0.008711393
#regression coefficients
coef(Employeecv.out,s=lambda_1se)
## 65 x 1 sparse Matrix of class "dgCMatrix"
##                                                1
## (Intercept)                         -3.102583695
## (Intercept)                          .          
## Age                                 -0.018037705
## `BusinessTravel.Non-Travel`         -0.187340587
## BusinessTravel.Travel_Frequently     0.648785428
## BusinessTravel.Travel_Rarely         .          
## `Department.Human Resources`         0.448111748
## `Department.Research & Development`  .          
## Department.Sales                     .          
## DistanceFromHome                     .          
## Education.Bachelor                   .          
## Education.BelowCollege               .          
## Education.College                    0.050442331
## Education.Doctor                    -0.147145892
## Education.Master                     .          
## `EducationField.Human Resources`     0.502228683
## `EducationField.Life Sciences`       .          
## EducationField.Marketing             .          
## EducationField.Medical               .          
## EducationField.Other                 .          
## `EducationField.Technical Degree`   -0.019872633
## EmployeeCount                        .          
## Gender.Female                        .          
## Gender.Male                          .          
## JobLevel                             .          
## `JobRole.Healthcare Representative`  .          
## `JobRole.Human Resources`            .          
## `JobRole.Laboratory Technician`      .          
## JobRole.Manager                     -0.013148895
## `JobRole.Manufacturing Director`    -0.327248865
## `JobRole.Research Director`          0.016752683
## `JobRole.Research Scientist`         .          
## `JobRole.Sales Executive`            0.040457177
## `JobRole.Sales Representative`      -0.093015980
## MaritalStatus.Divorced              -0.029924613
## MaritalStatus.Married                .          
## MaritalStatus.Single                 0.791627971
## MonthlyIncome                        .          
## NumCompaniesWorked                   0.048682074
## PercentSalaryHike                    0.006034498
## StandardHours                        .          
## StockOptionLevel                     .          
## TotalWorkingYears                   -0.042886061
## TrainingTimesLastYear               -0.048081530
## YearsAtCompany                       .          
## YearsSinceLastPromotion              0.083469293
## YearsWithCurrManager                -0.099049961
## EnvironmentSatisfaction             -0.202395024
## JobSatisfaction.High                 .          
## JobSatisfaction.Low                  0.270662708
## JobSatisfaction.Medium               .          
## JobSatisfaction.VeryHigh            -0.434123270
## JobSatisfaction.NA                   .          
## WorkLifeBalance.Bad                  0.683544734
## WorkLifeBalance.Best                 .          
## WorkLifeBalance.Better              -0.219772865
## WorkLifeBalance.Good                 .          
## WorkLifeBalance.NA                   .          
## JobInvolvement.High                  .          
## JobInvolvement.Low                   0.180668452
## JobInvolvement.Medium                .          
## JobInvolvement.VeryHigh              .          
## PerformanceRating.Excellent          .          
## PerformanceRating.Outstanding        .          
## OfficeAvgduration                    0.362464419

Validating the test data prediction after regularisation

Let’s see by running the model against our test data:

#get test data
x_test <- model.matrix(consolidated_employee_regression_val$Attrition~.,consolidated_employee_regression_val)
#predict class, type="class"
lasso_prob <- predict(Employeecv.out, newx = x_test, s=lambda_1se,type="response")

consolidated_employee_regression_val_filtered$AttritionPredictedLasso <- ifelse(lasso_prob  > 0.5,1,0)  ### assigning the probability to value. Note here that we have taken the data frame where null values being removed because o\p-valuye is not there for null values,

EmployeeAttritionLasso <- table(actualclass=consolidated_employee_regression_val_filtered$Attrition, predictedclass=consolidated_employee_regression_val_filtered$AttritionPredictedLasso)

confusionMatrix(EmployeeAttritionLasso)
## Confusion Matrix and Statistics
## 
##            predictedclass
## actualclass    0    1
##           0 1096   12
##           1  185   28
##                                           
##                Accuracy : 0.8509          
##                  95% CI : (0.8305, 0.8697)
##     No Information Rate : 0.9697          
##     P-Value [Acc > NIR] : 1               
##                                           
##                   Kappa : 0.1795          
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.8556          
##             Specificity : 0.7000          
##          Pos Pred Value : 0.9892          
##          Neg Pred Value : 0.1315          
##              Prevalence : 0.9697          
##          Detection Rate : 0.8297          
##    Detection Prevalence : 0.8388          
##       Balanced Accuracy : 0.7778          
##                                           
##        'Positive' Class : 0               
##