Update README.md
Browse files
README.md
CHANGED
@@ -1,77 +1,80 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
-
|
19 |
-
-
|
20 |
-
-
|
21 |
-
-
|
22 |
-
-
|
23 |
-
-
|
24 |
-
-
|
25 |
-
-
|
26 |
-
-
|
27 |
-
-
|
28 |
-
-
|
29 |
-
-
|
30 |
-
-
|
31 |
-
-
|
32 |
-
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
'
|
54 |
-
'
|
55 |
-
'
|
56 |
-
'
|
57 |
-
'
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
'
|
71 |
-
'
|
72 |
-
'
|
73 |
-
'
|
74 |
-
'
|
75 |
-
'
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
inference: true
|
6 |
+
---
|
7 |
+
# HR Attrition Model
|
8 |
+
|
9 |
+
This model predicts the survival function of employees based on various features using a Cox Proportional Hazards model. The model aims to estimate how long an employee is likely to stay at the company based on a variety of factors.
|
10 |
+
|
11 |
+
## Model Description
|
12 |
+
|
13 |
+
The HR Attrition Model leverages the Cox Proportional Hazards method to predict employee retention. Key features used in this model include demographic information, job details, and work-life balance metrics. The model is trained on the "HR_Attrition" dataset and is designed to help HR departments understand employee attrition risks.
|
14 |
+
|
15 |
+
## Features
|
16 |
+
|
17 |
+
The following features are used for predictions:
|
18 |
+
- Age
|
19 |
+
- DistanceFromHome
|
20 |
+
- Education
|
21 |
+
- NumCompaniesWorked
|
22 |
+
- PercentSalaryHike
|
23 |
+
- TotalWorkingYears
|
24 |
+
- TrainingTimesLastYear
|
25 |
+
- WorkLifeBalance
|
26 |
+
- YearsInCurrentRole
|
27 |
+
- YearsSinceLastPromotion
|
28 |
+
- YearsWithCurrManager
|
29 |
+
- BusinessTravel (Travel_Rarely, Travel_Frequently)
|
30 |
+
- Department (Research & Development, Sales)
|
31 |
+
- EducationField (Life Sciences, Medical, Marketing, Other, Technical Degree)
|
32 |
+
- Gender (Male)
|
33 |
+
- JobRole (Research Scientist, Sales Executive, Laboratory Technician, Manufacturing Director, Healthcare Representative, Manager, Sales Representative, Research Director)
|
34 |
+
- MaritalStatus (Married, Single)
|
35 |
+
- OverTime (Yes)
|
36 |
+
|
37 |
+
## Usage
|
38 |
+
|
39 |
+
To use this model, you need to load the model and pass the input features in the required format.
|
40 |
+
|
41 |
+
### Example
|
42 |
+
|
43 |
+
Here is an example of how to use the model to predict the survival function:
|
44 |
+
|
45 |
+
```python
|
46 |
+
import joblib
|
47 |
+
import pandas as pd
|
48 |
+
|
49 |
+
class HRAttritionModel:
|
50 |
+
def __init__(self, model_path):
|
51 |
+
self.model = joblib.load(model_path)
|
52 |
+
self.features = ['Age', 'DistanceFromHome', 'Education', 'NumCompaniesWorked', 'PercentSalaryHike',
|
53 |
+
'TotalWorkingYears', 'TrainingTimesLastYear', 'WorkLifeBalance', 'YearsInCurrentRole',
|
54 |
+
'YearsSinceLastPromotion', 'YearsWithCurrManager', 'BusinessTravel_Travel_Rarely',
|
55 |
+
'BusinessTravel_Travel_Frequently', 'Department_Research & Development', 'Department_Sales',
|
56 |
+
'EducationField_Life Sciences', 'EducationField_Medical', 'EducationField_Marketing',
|
57 |
+
'EducationField_Other', 'EducationField_Technical Degree', 'Gender_Male', 'JobRole_Research Scientist',
|
58 |
+
'JobRole_Sales Executive', 'JobRole_Laboratory Technician', 'JobRole_Manufacturing Director',
|
59 |
+
'JobRole_Healthcare Representative', 'JobRole_Manager', 'JobRole_Sales Representative',
|
60 |
+
'JobRole_Research Director', 'MaritalStatus_Married', 'MaritalStatus_Single', 'OverTime_Yes']
|
61 |
+
|
62 |
+
def predict_survival(self, input_data):
|
63 |
+
df = pd.DataFrame([input_data], columns=self.features)
|
64 |
+
survival_function = self.model.predict_survival_function(df)
|
65 |
+
return survival_function.T
|
66 |
+
|
67 |
+
# Load the model and make a prediction
|
68 |
+
model = HRAttritionModel('cox_model.pkl')
|
69 |
+
sample_input = {'Age': 41, 'DistanceFromHome': 1, 'Education': 2, 'NumCompaniesWorked': 1, 'PercentSalaryHike': 11,
|
70 |
+
'TotalWorkingYears': 8, 'TrainingTimesLastYear': 0, 'WorkLifeBalance': 1, 'YearsInCurrentRole': 4,
|
71 |
+
'YearsSinceLastPromotion': 0, 'YearsWithCurrManager': 5, 'BusinessTravel_Travel_Rarely': 1,
|
72 |
+
'BusinessTravel_Travel_Frequently': 0, 'Department_Research & Development': 0, 'Department_Sales': 1,
|
73 |
+
'EducationField_Life Sciences': 1, 'EducationField_Medical': 0, 'EducationField_Marketing': 0,
|
74 |
+
'EducationField_Other': 0, 'EducationField_Technical Degree': 0, 'Gender_Male': 1,
|
75 |
+
'JobRole_Research Scientist': 0, 'JobRole_Sales Executive': 0, 'JobRole_Laboratory Technician': 0,
|
76 |
+
'JobRole_Manufacturing Director': 0, 'JobRole_Healthcare Representative': 0, 'JobRole_Manager': 0,
|
77 |
+
'JobRole_Sales Representative': 0, 'JobRole_Research Director': 0, 'MaritalStatus_Married': 0,
|
78 |
+
'MaritalStatus_Single': 1, 'OverTime_Yes': 0}
|
79 |
+
prediction = model.predict_survival(sample_input)
|
80 |
+
print(prediction)
|