rasmodev commited on
Commit
226dd1b
·
verified ·
1 Parent(s): 1d2f854

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -14
app.py CHANGED
@@ -22,50 +22,58 @@ def main():
22
  st.write(f"- {column}: {values}")
23
 
24
  # Main content
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
 
 
30
  with col1:
31
  age = st.slider("Age", min_value=18, max_value=70, value=30)
32
  distance_from_home = st.slider("Distance From Home", min_value=1, max_value=30, value=10)
33
- environment_satisfaction = st.slider("Environment Satisfaction", min_value=1, max_value=4, value=2)
34
  hourly_rate = st.slider("Hourly Rate", min_value=30, max_value=100, value=65)
35
- job_involvement = st.slider("Job Involvement", min_value=1, max_value=4, value=2) # Change to Job Involvement
36
-
 
37
  with col2:
 
 
38
  monthly_income = st.slider("Monthly Income", min_value=1000, max_value=20000, value=5000)
39
  num_companies_worked = st.slider("Number of Companies Worked", min_value=0, max_value=10, value=2)
40
- percent_salary_hike = st.slider("Percent Salary Hike", min_value=10, max_value=25, value=15)
41
- stock_option_level = st.slider("Stock Option Level", min_value=0, max_value=3, value=1)
42
- training_times_last_year = st.slider("Training Times Last Year", min_value=0, max_value=6, value=2)
43
 
 
44
  with col3:
45
- work_life_balance = st.slider("Work Life Balance", min_value=1, max_value=4, value=2)
 
 
 
46
  years_since_last_promotion = st.slider("Years Since Last Promotion", min_value=0, max_value=15, value=3)
47
  years_with_curr_manager = st.slider("Years With Current Manager", min_value=0, max_value=15, value=3)
48
 
49
- over_time = st.checkbox("Over Time")
50
-
51
  # Create a DataFrame to hold the user input data
52
  input_data = pd.DataFrame({
53
  'Age': [age],
54
  'DistanceFromHome': [distance_from_home],
55
  'EnvironmentSatisfaction': [environment_satisfaction],
56
  'HourlyRate': [hourly_rate],
 
 
57
  'JobSatisfaction': [job_satisfaction],
58
  'MonthlyIncome': [monthly_income],
59
  'NumCompaniesWorked': [num_companies_worked],
 
60
  'PercentSalaryHike': [percent_salary_hike],
61
  'StockOptionLevel': [stock_option_level],
62
  'TrainingTimesLastYear': [training_times_last_year],
63
  'WorkLifeBalance': [work_life_balance],
64
  'YearsSinceLastPromotion': [years_since_last_promotion],
65
- 'YearsWithCurrManager': [years_with_curr_manager],
66
- 'OverTime': [over_time]
67
  })
68
-
69
  # Make predictions
70
  prediction = model.predict(input_data)
71
  probability = model.predict_proba(input_data)[:, 1]
 
22
  st.write(f"- {column}: {values}")
23
 
24
  # Main content
25
+ st.write("Welcome to the Employee Attrition Prediction App!")
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
  distance_from_home = st.slider("Distance From Home", min_value=1, max_value=30, value=10)
36
+ environment_satisfaction = st.select_slider("Environment Satisfaction", options=[1, 2, 3, 4], value=2)
37
  hourly_rate = st.slider("Hourly Rate", min_value=30, max_value=100, value=65)
38
+ job_involvement = st.select_slider("Job Involvement", options=[1, 2, 3, 4], value=2)
39
+
40
+ # Column 2
41
  with col2:
42
+ job_level = st.select_slider("Job Level", options=[1, 2, 3, 4, 5], value=3)
43
+ job_satisfaction = st.select_slider("Job Satisfaction", options=[1, 2, 3, 4], value=2)
44
  monthly_income = st.slider("Monthly Income", min_value=1000, max_value=20000, value=5000)
45
  num_companies_worked = st.slider("Number of Companies Worked", min_value=0, max_value=10, value=2)
46
+ over_time = st.checkbox("Over Time")
 
 
47
 
48
+ # Column 3
49
  with col3:
50
+ percent_salary_hike = st.slider("Percent Salary Hike", min_value=10, max_value=25, value=15)
51
+ stock_option_level = st.select_slider("Stock Option Level", options=[0, 1, 2, 3], value=1)
52
+ training_times_last_year = st.slider("Training Times Last Year", min_value=0, max_value=6, value=2)
53
+ work_life_balance = st.select_slider("Work Life Balance", options=[1, 2, 3, 4], value=2)
54
  years_since_last_promotion = st.slider("Years Since Last Promotion", min_value=0, max_value=15, value=3)
55
  years_with_curr_manager = st.slider("Years With Current Manager", min_value=0, max_value=15, value=3)
56
 
 
 
57
  # Create a DataFrame to hold the user input data
58
  input_data = pd.DataFrame({
59
  'Age': [age],
60
  'DistanceFromHome': [distance_from_home],
61
  'EnvironmentSatisfaction': [environment_satisfaction],
62
  'HourlyRate': [hourly_rate],
63
+ 'JobInvolvement': [job_involvement],
64
+ 'JobLevel': [job_level],
65
  'JobSatisfaction': [job_satisfaction],
66
  'MonthlyIncome': [monthly_income],
67
  'NumCompaniesWorked': [num_companies_worked],
68
+ 'OverTime': [over_time],
69
  'PercentSalaryHike': [percent_salary_hike],
70
  'StockOptionLevel': [stock_option_level],
71
  'TrainingTimesLastYear': [training_times_last_year],
72
  'WorkLifeBalance': [work_life_balance],
73
  'YearsSinceLastPromotion': [years_since_last_promotion],
74
+ 'YearsWithCurrManager': [years_with_curr_manager]
 
75
  })
76
+
77
  # Make predictions
78
  prediction = model.predict(input_data)
79
  probability = model.predict_proba(input_data)[:, 1]