rasmodev commited on
Commit
7849dfa
1 Parent(s): 41a5a36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -30
app.py CHANGED
@@ -25,35 +25,35 @@ def main():
25
  st.write("This app predicts employee attrition using a trained CatBoost model.")
26
 
27
  # Add inputs for user to input data
28
- age = st.slider("Age", min_value=18, max_value=70, value=30)
29
- distance_from_home = st.slider("Distance From Home", min_value=1, max_value=30, value=10)
30
- environment_satisfaction = st.slider("Environment Satisfaction", min_value=1, max_value=4, value=2)
31
- hourly_rate = st.slider("Hourly Rate", min_value=30, max_value=100, value=65)
32
- job_involvement = st.slider("Job Involvement", min_value=1, max_value=4, value=2)
33
- job_level = st.slider("Job Level", min_value=1, max_value=5, value=3)
34
- job_satisfaction = st.slider("Job Satisfaction", min_value=1, max_value=4, value=2)
35
- monthly_income = st.slider("Monthly Income", min_value=1000, max_value=20000, value=5000)
36
- num_companies_worked = st.slider("Number of Companies Worked", min_value=0, max_value=10, value=2)
37
- over_time = st.checkbox("Over Time")
38
- percent_salary_hike = st.slider("Percent Salary Hike", min_value=10, max_value=25, value=15)
39
- stock_option_level = st.slider("Stock Option Level", min_value=0, max_value=3, value=1)
40
- training_times_last_year = st.slider("Training Times Last Year", min_value=0, max_value=6, value=2)
41
- work_life_balance = st.slider("Work Life Balance", min_value=1, max_value=4, value=2)
42
- years_since_last_promotion = st.slider("Years Since Last Promotion", min_value=0, max_value=15, value=3)
43
- years_with_curr_manager = st.slider("Years With Current Manager", min_value=0, max_value=15, value=3)
 
 
44
 
45
  # Create a DataFrame to hold the user input data
46
  input_data = pd.DataFrame({
47
  'Age': [age],
48
  'DistanceFromHome': [distance_from_home],
49
  'EnvironmentSatisfaction': [environment_satisfaction],
50
- 'HourlyRate': [hourly_rate],
51
- 'JobInvolvement': [job_involvement],
52
- 'JobLevel': [job_level],
53
  'JobSatisfaction': [job_satisfaction],
54
  'MonthlyIncome': [monthly_income],
55
  'NumCompaniesWorked': [num_companies_worked],
56
  'OverTime': [over_time],
 
57
  'PercentSalaryHike': [percent_salary_hike],
58
  'StockOptionLevel': [stock_option_level],
59
  'TrainingTimesLastYear': [training_times_last_year],
@@ -62,17 +62,6 @@ def main():
62
  'YearsWithCurrManager': [years_with_curr_manager]
63
  })
64
 
65
- # Suggestions for retaining the employee
66
- if predicted_to_leave:
67
- st.subheader("Suggestions for Retaining the Employee:")
68
- st.markdown("- Invest in orientation programs and career development for entry-level staff to contribute to higher retention.")
69
- st.markdown("- Implement mentorship programs and career development initiatives aimed at engaging and retaining younger employees.")
70
- st.markdown("- Offer robust training and development programs and regular promotion to foster career growth. This investment in skills and career advancement can contribute to higher job satisfaction and retention.")
71
- st.markdown("- Recognize the diverse needs of employees based on marital status and consider tailoring benefits or support programs accordingly.")
72
- st.markdown("- Consider offering benefits that cater to the unique needs of married, single, and divorced employees.")
73
- st.markdown("- Introduce or enhance policies that support work-life balance for employees with families.")
74
- st.markdown("- Recognize the unique challenges and opportunities within each department and tailor retention strategies accordingly.")
75
-
76
  # Make predictions
77
  prediction = model.predict(input_data)
78
  probability = model.predict_proba(input_data)[:, 1]
 
25
  st.write("This app predicts employee attrition using a trained CatBoost model.")
26
 
27
  # Add inputs for user to input data
28
+ col1, col2, col3 = st.columns(3)
29
+ with col1:
30
+ age = st.slider("Age", min_value=18, max_value=70, value=30)
31
+ environment_satisfaction = st.slider("Environment Satisfaction", min_value=1, max_value=4, value=2)
32
+ job_satisfaction = st.slider("Job Satisfaction", min_value=1, max_value=4, value=2)
33
+ monthly_income = st.slider("Monthly Income", min_value=1000, max_value=20000, value=5000)
34
+ over_time = st.checkbox("Over Time")
35
+ with col2:
36
+ distance_from_home = st.slider("Distance From Home", min_value=1, max_value=30, value=10)
37
+ job_involvement = st.slider("Job Involvement", min_value=1, max_value=4, value=2)
38
+ num_companies_worked = st.slider("Number of Companies Worked", min_value=0, max_value=10, value=2)
39
+ percent_salary_hike = st.slider("Percent Salary Hike", min_value=10, max_value=25, value=15)
40
+ stock_option_level = st.slider("Stock Option Level", min_value=0, max_value=3, value=1)
41
+ with col3:
42
+ training_times_last_year = st.slider("Training Times Last Year", min_value=0, max_value=6, value=2)
43
+ work_life_balance = st.slider("Work Life Balance", min_value=1, max_value=4, value=2)
44
+ years_since_last_promotion = st.slider("Years Since Last Promotion", min_value=0, max_value=15, value=3)
45
+ years_with_curr_manager = st.slider("Years With Current Manager", min_value=0, max_value=15, value=3)
46
 
47
  # Create a DataFrame to hold the user input data
48
  input_data = pd.DataFrame({
49
  'Age': [age],
50
  'DistanceFromHome': [distance_from_home],
51
  'EnvironmentSatisfaction': [environment_satisfaction],
 
 
 
52
  'JobSatisfaction': [job_satisfaction],
53
  'MonthlyIncome': [monthly_income],
54
  'NumCompaniesWorked': [num_companies_worked],
55
  'OverTime': [over_time],
56
+ 'JobInvolvement': [job_involvement],
57
  'PercentSalaryHike': [percent_salary_hike],
58
  'StockOptionLevel': [stock_option_level],
59
  'TrainingTimesLastYear': [training_times_last_year],
 
62
  'YearsWithCurrManager': [years_with_curr_manager]
63
  })
64
 
 
 
 
 
 
 
 
 
 
 
 
65
  # Make predictions
66
  prediction = model.predict(input_data)
67
  probability = model.predict_proba(input_data)[:, 1]