xeroISB commited on
Commit
160b49e
·
1 Parent(s): d05b013
Files changed (1) hide show
  1. README.md +74 -0
README.md CHANGED
@@ -1,3 +1,77 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)