Srishti Puri
4/22/2021
- Perform any initial data preparations.
- Split the data into training and validation.
- Develop an initial model.
- Which are the most important variables.
- Report on the accuracy of the model.
- Interpret two (2) complete paths.
The model accurately predicted 98.9% of the loyal employees.
The model accurately predicted 92.4% of the left employees.
The model is 97.4% of the times correct.
The model inaccurately predicted 1.1% of the employees to leave.
The model inaccurately predicted 7.6% of the employees as loyal.
2.6% of the times the model is incorrect.
##
##
## Cell Contents
## |-------------------------|
## | N |
## | Chi-square contribution |
## | N / Row Total |
## | N / Col Total |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 4459
##
##
## | val$left_predicted
## val$left | 0 | 1 | Row Total |
## -------------|-----------|-----------|-----------|
## 0 | 3362 | 37 | 3399 |
## | 207.226 | 702.243 | |
## | 0.989 | 0.011 | 0.762 |
## | 0.976 | 0.036 | |
## | 0.754 | 0.008 | |
## -------------|-----------|-----------|-----------|
## 1 | 81 | 979 | 1060 |
## | 664.491 | 2251.814 | |
## | 0.076 | 0.924 | 0.238 |
## | 0.024 | 0.964 | |
## | 0.018 | 0.220 | |
## -------------|-----------|-----------|-----------|
## Column Total | 3443 | 1016 | 4459 |
## | 0.772 | 0.228 | |
## -------------|-----------|-----------|-----------|
##
##
There are 8 continuous variables and 2 categorical variables.
Satisfaction level: Most employees are highly satisfied.
Last Evaluation: Most employees are good performers with 75% of the data set being evaluated between 56 percent - 87 percent.
Number of Projects: Most employees do a reasonable number of projects.
Average Monthly Hours: Most employees spend, fairly, a higher amount of hours at work.
Time Spent in Company: Fewer employees stay beyond 4 years.
## var frequency percentage cumulative_perc
## 1 0 12830 85.54 85.54
## 2 1 2169 14.46 100.00
## var frequency percentage cumulative_perc
## 1 0 14680 97.87 97.87
## 2 1 319 2.13 100.00
## var frequency percentage cumulative_perc
## 1 0 11428 76.19 76.19
## 2 1 3571 23.81 100.00
## var frequency percentage cumulative_perc
## 1 low 7316 48.78 48.78
## 2 medium 6446 42.98 91.76
## 3 high 1237 8.25 100.00
## var frequency percentage cumulative_perc
## 1 sales 4140 27.60 27.60
## 2 technical 2720 18.13 45.73
## 3 support 2229 14.86 60.59
## 4 IT 1227 8.18 68.77
## 5 product_mng 902 6.01 74.78
## 6 marketing 858 5.72 80.50
## 7 RandD 787 5.25 85.75
## 8 accounting 767 5.11 90.86
## 9 hr 739 4.93 95.79
## 10 management 630 4.20 100.00
Mutated factors of the categorical variables: salary, sales and left.
Created a new variable ‘random’ using the runif() function to generate random deviates of the uniform distribution.
To split data into training (train) and test set: validation (val)
- train (10540 observations with 10 variables) and
- val (4459 observations with 10 variables).
## CP nsplit rel error xerror xstd
## 1 0.25766627 0 1.0000000 1.0000000 0.017417550
## 2 0.17960972 1 0.7423337 0.7423337 0.015599681
## 3 0.07347670 3 0.3831143 0.3831143 0.011774919
## 4 0.05137395 5 0.2361609 0.2361609 0.009421204
## 5 0.03305456 6 0.1847869 0.1855834 0.008404791
## 6 0.01632816 7 0.1517324 0.1525289 0.007650945
## 7 0.01035444 8 0.1354042 0.1385902 0.007305540
## 8 0.01000000 9 0.1250498 0.1330147 0.007161995
At the top when no condition is applied on the training data set (train) the best guess is determined as 0 (NOT left).
Ergo, of the total observations 76% did not leave and 24% left.
First condition: satisfaction_level >= 47 percent.
Second condition: time_spend_company < 5 years.
Third condition: last_evaluation < 81 percent.
Hence, those who did NOT leave are highly satisfied, have spent at least 4 years in the organization and are good performers with an evaluation of at least 80 percent.
First condition: satisfaction_level < 47 percent.
Second condition: number_project >= 3 projects.
Third condition: last_evaluation >= 58 percent.
Hence, those who leave are lowly or moderately satisfied, have a work load of 3 or more projects with their performance being evaluated at least 58 percent.
## variable_importance
## satisfaction_level 2127.439578
## number_project 1074.512028
## average_montly_hours 1052.234047
## last_evaluation 1039.697458
## time_spend_company 814.319253
## Work_accident 30.746512
## promotion_last_5years 7.838264
## sales 5.842639
Total number of employees left: 1060
Total number of employees predicted to leave: 1016
Total number of loyal employees: 3399
Total number of employees predicted as loyal: 3443
## satisfaction_level last_evaluation number_project average_montly_hours
## Min. :0.0900 Min. :0.3600 Min. :2.000 Min. : 97.0
## 1st Qu.:0.4400 1st Qu.:0.5600 1st Qu.:3.000 1st Qu.:156.0
## Median :0.6400 Median :0.7200 Median :4.000 Median :200.0
## Mean :0.6112 Mean :0.7181 Mean :3.792 Mean :201.7
## 3rd Qu.:0.8100 3rd Qu.:0.8700 3rd Qu.:5.000 3rd Qu.:247.0
## Max. :1.0000 Max. :1.0000 Max. :7.000 Max. :310.0
##
## time_spend_company Work_accident left promotion_last_5years
## Min. : 2.000 Min. :0.0000 0:3399 Min. :0.00000
## 1st Qu.: 3.000 1st Qu.:0.0000 1:1060 1st Qu.:0.00000
## Median : 3.000 Median :0.0000 Median :0.00000
## Mean : 3.493 Mean :0.1518 Mean :0.02108
## 3rd Qu.: 4.000 3rd Qu.:0.0000 3rd Qu.:0.00000
## Max. :10.000 Max. :1.0000 Max. :1.00000
##
## sales salary left_predicted
## sales :1240 high : 349 0:3443
## technical : 829 low :2135 1:1016
## support : 655 medium:1975
## IT : 367
## product_mng: 271
## marketing : 267
## (Other) : 830