rasmodev commited on
Commit
bbe87d6
1 Parent(s): e2b803d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -38
app.py CHANGED
@@ -26,58 +26,41 @@ def main():
26
  st.write("This app helps HR practitioners predict employee attrition using a trained CatBoost model.")
27
  st.write("Please provide the following information to make a prediction:")
28
 
29
- # Define layout with three columns
30
- col1, col2, col3 = st.columns(3)
31
 
32
  # Column 1
33
  with col1:
34
- age = st.slider("Age", min_value=18, max_value=70, value=30)
35
- business_travel = st.selectbox("Business Travel", options=['Travel_Rarely', 'Travel_Frequently', 'Non-Travel'])
36
- department = st.selectbox("Department", options=['Sales', 'Research & Development', 'Human Resources'])
37
- education_field = st.selectbox("Education Field", options=['Life Sciences', 'Other', 'Medical', 'Marketing', 'Technical Degree', 'Human Resources'])
38
- environment_satisfaction = st.select_slider("Environment Satisfaction", options=[1, 2, 3, 4], value=2)
39
- gender = st.radio("Gender", options=['Female', 'Male'])
40
- job_role = st.selectbox("Job Role", options=['Sales Executive', 'Research Scientist', 'Laboratory Technician', 'Manufacturing Director', 'Healthcare Representative', 'Manager', 'Sales Representative', 'Research Director', 'Human Resources'])
41
- job_satisfaction = st.select_slider("Job Satisfaction", options=[1, 2, 3, 4], value=2)
42
 
43
  # Column 2
44
  with col2:
45
- monthly_income = st.slider("Monthly Income", min_value=1000, max_value=20000, value=5000)
46
- num_companies_worked = st.slider("Number of Companies Worked", min_value=0, max_value=10, value=2)
47
  over_time = st.checkbox("Over Time")
48
- percent_salary_hike = st.slider("Percent Salary Hike", min_value=10, max_value=25, value=15)
49
- relationship_satisfaction = st.select_slider("Relationship Satisfaction", options=[1, 2, 3, 4], value=2)
50
- stock_option_level = st.select_slider("Stock Option Level", options=[0, 1, 2, 3], value=1)
51
-
52
- # Column 3
53
- with col3:
54
- training_times_last_year = st.slider("Training Times Last Year", min_value=0, max_value=6, value=2)
55
- work_life_balance = st.select_slider("Work Life Balance", options=[1, 2, 3, 4], value=2)
56
- years_at_company = st.slider("Years at Company", min_value=0, max_value=40, value=5)
57
- years_since_last_promotion = st.slider("Years Since Last Promotion", min_value=0, max_value=15, value=3)
58
- years_with_curr_manager = st.slider("Years With Current Manager", min_value=0, max_value=17, value=5)
59
 
60
  # Create a DataFrame to hold the user input data
61
  input_data = pd.DataFrame({
62
  'Age': [age],
63
- 'BusinessTravel': [business_travel],
64
- 'Department': [department],
65
- 'EducationField': [education_field],
66
- 'EnvironmentSatisfaction': [environment_satisfaction],
67
- 'Gender': [gender],
68
- 'JobRole': [job_role],
69
- 'JobSatisfaction': [job_satisfaction],
70
  'MonthlyIncome': [monthly_income],
71
  'NumCompaniesWorked': [num_companies_worked],
72
- 'OverTime': [over_time],
73
  'PercentSalaryHike': [percent_salary_hike],
74
- 'RelationshipSatisfaction': [relationship_satisfaction],
75
- 'StockOptionLevel': [stock_option_level],
76
  'TrainingTimesLastYear': [training_times_last_year],
77
- 'WorkLifeBalance': [work_life_balance],
78
- 'YearsAtCompany': [years_at_company],
79
  'YearsSinceLastPromotion': [years_since_last_promotion],
80
- 'YearsWithCurrManager': [years_with_curr_manager]
 
 
 
 
 
81
  })
82
 
83
  # Make predictions
@@ -101,7 +84,7 @@ def main():
101
  st.markdown("- Recognize the unique challenges and opportunities within each department and tailor retention strategies accordingly.")
102
 
103
  # Display probability
104
- st.write(f"Probability of Attrition: {probability[0]:.2f}")
105
 
106
  if __name__ == "__main__":
107
- main()
 
26
  st.write("This app helps HR practitioners predict employee attrition using a trained CatBoost model.")
27
  st.write("Please provide the following information to make a prediction:")
28
 
29
+ # Define layout with two columns
30
+ col1, col2 = st.columns(2)
31
 
32
  # Column 1
33
  with col1:
34
+ age = st.slider("Age", min_value=18, max_value=70)
35
+ monthly_income = st.slider("Monthly Income", min_value=1000, max_value=20000)
36
+ num_companies_worked = st.slider("Number of Companies Worked", min_value=0, max_value=10)
37
+ percent_salary_hike = st.slider("Percent Salary Hike", min_value=10, max_value=25)
38
+ training_times_last_year = st.slider("Training Times Last Year", min_value=0, max_value=6)
39
+ years_since_last_promotion = st.slider("Years Since Last Promotion", min_value=0, max_value=15)
40
+ years_with_curr_manager = st.slider("Years With Current Manager", min_value=0, max_value=15)
 
41
 
42
  # Column 2
43
  with col2:
 
 
44
  over_time = st.checkbox("Over Time")
45
+ work_life_balance = st.select_slider("Work Life Balance", options=[1, 2, 3, 4])
46
+ environment_satisfaction = st.select_slider("Environment Satisfaction", options=[1, 2, 3, 4])
47
+ job_satisfaction = st.select_slider("Job Satisfaction", options=[1, 2, 3, 4])
48
+ relationship_satisfaction = st.select_slider("Relationship Satisfaction", options=[1, 2, 3, 4])
 
 
 
 
 
 
 
49
 
50
  # Create a DataFrame to hold the user input data
51
  input_data = pd.DataFrame({
52
  'Age': [age],
 
 
 
 
 
 
 
53
  'MonthlyIncome': [monthly_income],
54
  'NumCompaniesWorked': [num_companies_worked],
 
55
  'PercentSalaryHike': [percent_salary_hike],
 
 
56
  'TrainingTimesLastYear': [training_times_last_year],
 
 
57
  'YearsSinceLastPromotion': [years_since_last_promotion],
58
+ 'YearsWithCurrManager': [years_with_curr_manager],
59
+ 'OverTime': [over_time],
60
+ 'WorkLifeBalance': [work_life_balance],
61
+ 'EnvironmentSatisfaction': [environment_satisfaction],
62
+ 'JobSatisfaction': [job_satisfaction],
63
+ 'RelationshipSatisfaction': [relationship_satisfaction]
64
  })
65
 
66
  # Make predictions
 
84
  st.markdown("- Recognize the unique challenges and opportunities within each department and tailor retention strategies accordingly.")
85
 
86
  # Display probability
87
+ st.write(f"Probability of Attrition: {probability[0]*100:.2f}%")
88
 
89
  if __name__ == "__main__":
90
+ main()