xeroISB commited on
Commit
cb0befc
·
verified ·
1 Parent(s): 160b49e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +80 -77
README.md CHANGED
@@ -1,77 +1,80 @@
1
- ---
2
- license: apache-2.0
3
- ---
4
- # HR Attrition Model
5
-
6
- 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.
7
-
8
- ## Model Description
9
-
10
- 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.
11
-
12
- ## Features
13
-
14
- The following features are used for predictions:
15
- - Age
16
- - DistanceFromHome
17
- - Education
18
- - NumCompaniesWorked
19
- - PercentSalaryHike
20
- - TotalWorkingYears
21
- - TrainingTimesLastYear
22
- - WorkLifeBalance
23
- - YearsInCurrentRole
24
- - YearsSinceLastPromotion
25
- - YearsWithCurrManager
26
- - BusinessTravel (Travel_Rarely, Travel_Frequently)
27
- - Department (Research & Development, Sales)
28
- - EducationField (Life Sciences, Medical, Marketing, Other, Technical Degree)
29
- - Gender (Male)
30
- - JobRole (Research Scientist, Sales Executive, Laboratory Technician, Manufacturing Director, Healthcare Representative, Manager, Sales Representative, Research Director)
31
- - MaritalStatus (Married, Single)
32
- - OverTime (Yes)
33
-
34
- ## Usage
35
-
36
- To use this model, you need to load the model and pass the input features in the required format.
37
-
38
- ### Example
39
-
40
- Here is an example of how to use the model to predict the survival function:
41
-
42
- ```python
43
- import joblib
44
- import pandas as pd
45
-
46
- class HRAttritionModel:
47
- def __init__(self, model_path):
48
- self.model = joblib.load(model_path)
49
- self.features = ['Age', 'DistanceFromHome', 'Education', 'NumCompaniesWorked', 'PercentSalaryHike',
50
- 'TotalWorkingYears', 'TrainingTimesLastYear', 'WorkLifeBalance', 'YearsInCurrentRole',
51
- 'YearsSinceLastPromotion', 'YearsWithCurrManager', 'BusinessTravel_Travel_Rarely',
52
- 'BusinessTravel_Travel_Frequently', 'Department_Research & Development', 'Department_Sales',
53
- 'EducationField_Life Sciences', 'EducationField_Medical', 'EducationField_Marketing',
54
- 'EducationField_Other', 'EducationField_Technical Degree', 'Gender_Male', 'JobRole_Research Scientist',
55
- 'JobRole_Sales Executive', 'JobRole_Laboratory Technician', 'JobRole_Manufacturing Director',
56
- 'JobRole_Healthcare Representative', 'JobRole_Manager', 'JobRole_Sales Representative',
57
- 'JobRole_Research Director', 'MaritalStatus_Married', 'MaritalStatus_Single', 'OverTime_Yes']
58
-
59
- def predict_survival(self, input_data):
60
- df = pd.DataFrame([input_data], columns=self.features)
61
- survival_function = self.model.predict_survival_function(df)
62
- return survival_function.T
63
-
64
- # Load the model and make a prediction
65
- model = HRAttritionModel('cox_model.pkl')
66
- sample_input = {'Age': 41, 'DistanceFromHome': 1, 'Education': 2, 'NumCompaniesWorked': 1, 'PercentSalaryHike': 11,
67
- 'TotalWorkingYears': 8, 'TrainingTimesLastYear': 0, 'WorkLifeBalance': 1, 'YearsInCurrentRole': 4,
68
- 'YearsSinceLastPromotion': 0, 'YearsWithCurrManager': 5, 'BusinessTravel_Travel_Rarely': 1,
69
- 'BusinessTravel_Travel_Frequently': 0, 'Department_Research & Development': 0, 'Department_Sales': 1,
70
- 'EducationField_Life Sciences': 1, 'EducationField_Medical': 0, 'EducationField_Marketing': 0,
71
- 'EducationField_Other': 0, 'EducationField_Technical Degree': 0, 'Gender_Male': 1,
72
- 'JobRole_Research Scientist': 0, 'JobRole_Sales Executive': 0, 'JobRole_Laboratory Technician': 0,
73
- 'JobRole_Manufacturing Director': 0, 'JobRole_Healthcare Representative': 0, 'JobRole_Manager': 0,
74
- 'JobRole_Sales Representative': 0, 'JobRole_Research Director': 0, 'MaritalStatus_Married': 0,
75
- 'MaritalStatus_Single': 1, 'OverTime_Yes': 0}
76
- prediction = model.predict_survival(sample_input)
77
- print(prediction)
 
 
 
 
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)