Downloads · 30 days
0
xeroISB/EmployeeSurvivalRate
EmployeeSurvivalRate is a machine learning model from xeroISB. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
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 vari…
Downloads · 30 days
0
Access
Public
Updated Aug 4, 2024
Repo size
—
Likes
0
Public
Click a slice to open those files.
.pkl200 KB · 96%
From the Hugging Face model README
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.
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.
The following features are used for predictions:
To use this model, you need to load the model and pass the input features in the required format.
Here is an example of how to use the model to predict the survival function:
import joblib
import pandas as pd
class HRAttritionModel:
def __init__(self, model_path):
self.model = joblib.load(model_path)
self.features = ['Age', 'DistanceFromHome', 'Education', 'NumCompaniesWorked', 'PercentSalaryHike',
'TotalWorkingYears', 'TrainingTimesLastYear', 'WorkLifeBalance', 'YearsInCurrentRole',
'YearsSinceLastPromotion', 'YearsWithCurrManager', 'BusinessTravel_Travel_Rarely',
'BusinessTravel_Travel_Frequently', 'Department_Research & Development', 'Department_Sales',
'EducationField_Life Sciences', 'EducationField_Medical', 'EducationField_Marketing',
'EducationField_Other', 'EducationField_Technical Degree', 'Gender_Male', 'JobRole_Research Scientist',
'JobRole_Sales Executive', 'JobRole_Laboratory Technician', 'JobRole_Manufacturing Director',
'JobRole_Healthcare Representative', 'JobRole_Manager', 'JobRole_Sales Representative',
'JobRole_Research Director', 'MaritalStatus_Married', 'MaritalStatus_Single', 'OverTime_Yes']
def predict_survival(self, input_data):
df = pd.DataFrame([input_data], columns=self.features)
survival_function = self.model.predict_survival_function(df)
return survival_function.T
# Load the model and make a prediction
model = HRAttritionModel('cox_model.pkl')
sample_input = {'Age': 41, 'DistanceFromHome': 1, 'Education': 2, 'NumCompaniesWorked': 1, 'PercentSalaryHike': 11,
'TotalWorkingYears': 8, 'TrainingTimesLastYear': 0, 'WorkLifeBalance': 1, 'YearsInCurrentRole': 4,
'YearsSinceLastPromotion': 0, 'YearsWithCurrManager': 5, 'BusinessTravel_Travel_Rarely': 1,
'BusinessTravel_Travel_Frequently': 0, 'Department_Research & Development': 0, 'Department_Sales': 1,
'EducationField_Life Sciences': 1, 'EducationField_Medical': 0, 'EducationField_Marketing': 0,
'EducationField_Other': 0, 'EducationField_Technical Degree': 0, 'Gender_Male': 1,
'JobRole_Research Scientist': 0, 'JobRole_Sales Executive': 0, 'JobRole_Laboratory Technician': 0,
'JobRole_Manufacturing Director': 0, 'JobRole_Healthcare Representative': 0, 'JobRole_Manager': 0,
'JobRole_Sales Representative': 0, 'JobRole_Research Director': 0, 'MaritalStatus_Married': 0,
'MaritalStatus_Single': 1, 'OverTime_Yes': 0}
prediction = model.predict_survival(sample_input)
print(prediction)