Update app.py
Browse files
app.py
CHANGED
@@ -12,17 +12,17 @@ unique_values = saved_components['unique_values']
|
|
12 |
|
13 |
# Define the Streamlit app
|
14 |
def main():
|
15 |
-
st.title("Employee Attrition Prediction App")
|
16 |
-
st.sidebar.title("Model Settings")
|
17 |
|
18 |
# Sidebar inputs
|
19 |
-
with st.sidebar.expander("View Unique Values"):
|
20 |
st.write("Unique values for each feature:")
|
21 |
for column, values in unique_values.items():
|
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 |
|
@@ -55,7 +55,7 @@ def main():
|
|
55 |
years_with_curr_manager = st.number_input("Years With Current Manager")
|
56 |
|
57 |
# Predict button
|
58 |
-
if st.button("Predict"):
|
59 |
|
60 |
# Create a DataFrame to hold the user input data
|
61 |
input_data = pd.DataFrame({
|
@@ -84,37 +84,37 @@ def main():
|
|
84 |
# Make predictions
|
85 |
prediction = model.predict(input_data)
|
86 |
probability = model.predict_proba(input_data)[:, 1]
|
87 |
-
|
88 |
# Display prediction probability
|
89 |
if prediction[0] == 1:
|
90 |
-
st.subheader("Prediction Probability")
|
91 |
st.write(f"The probability of the employee leaving is: {probability[0]*100:.2f}%")
|
92 |
|
93 |
# Display characteristic-based recommendations
|
94 |
-
st.subheader("Recommendations for Retaining The Employee
|
95 |
if job_satisfaction == 1 or environment_satisfaction == 1:
|
96 |
st.markdown("- **Job and Environment Satisfaction**: Enhance job and environment satisfaction through initiatives such as recognition programs and improving workplace conditions.")
|
97 |
if years_since_last_promotion > 5:
|
98 |
-
st.markdown("- Implement a transparent promotion policy and provide opportunities for career advancement.")
|
99 |
if years_with_curr_manager > 5:
|
100 |
-
st.markdown("- Offer opportunities for a change in reporting structure to prevent stagnation and promote growth.")
|
101 |
if percent_salary_hike < 5:
|
102 |
-
st.markdown("- Consider adjusting salary and benefits packages to remain competitive and reward employee loyalty.")
|
103 |
if training_times_last_year < 2:
|
104 |
-
st.markdown("- Invest in employee development through training programs and continuous learning opportunities.")
|
105 |
if over_time:
|
106 |
-
st.markdown("- Evaluate workload distribution and consider implementing measures to prevent overwork, such as workload balancing and flexible scheduling.")
|
107 |
if relationship_satisfaction == 1:
|
108 |
-
st.markdown("- Foster positive relationships and a supportive work environment through team-building activities and open communication channels.")
|
109 |
if monthly_income < 5000:
|
110 |
-
st.markdown("- Review compensation structures and adjust salaries to align with industry standards and employee expectations.")
|
111 |
if num_companies_worked > 5:
|
112 |
-
st.markdown("- Identify reasons for high turnover and address issues related to job stability, career progression, and organizational culture.")
|
113 |
if work_life_balance == 1:
|
114 |
-
st.markdown("- Promote work-life balance initiatives, such as flexible work arrangements and wellness programs, to support employee well-being.")
|
115 |
|
116 |
# General recommendation for all negative predictions
|
117 |
-
st.markdown("- Conduct exit interviews to gather feedback and identify areas for improvement in retention strategies.")
|
118 |
|
119 |
if __name__ == "__main__":
|
120 |
main()
|
|
|
12 |
|
13 |
# Define the Streamlit app
|
14 |
def main():
|
15 |
+
st.title("Employee Attrition Prediction App π΅οΈββοΈ")
|
16 |
+
st.sidebar.title("Model Settings βοΈ")
|
17 |
|
18 |
# Sidebar inputs
|
19 |
+
with st.sidebar.expander("View Unique Values π"):
|
20 |
st.write("Unique values for each feature:")
|
21 |
for column, values in unique_values.items():
|
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 |
|
|
|
55 |
years_with_curr_manager = st.number_input("Years With Current Manager")
|
56 |
|
57 |
# Predict button
|
58 |
+
if st.button("Predict π"):
|
59 |
|
60 |
# Create a DataFrame to hold the user input data
|
61 |
input_data = pd.DataFrame({
|
|
|
84 |
# Make predictions
|
85 |
prediction = model.predict(input_data)
|
86 |
probability = model.predict_proba(input_data)[:, 1]
|
87 |
+
|
88 |
# Display prediction probability
|
89 |
if prediction[0] == 1:
|
90 |
+
st.subheader("Prediction Probability π")
|
91 |
st.write(f"The probability of the employee leaving is: {probability[0]*100:.2f}%")
|
92 |
|
93 |
# Display characteristic-based recommendations
|
94 |
+
st.subheader("Recommendations for Retaining The Employee π‘:")
|
95 |
if job_satisfaction == 1 or environment_satisfaction == 1:
|
96 |
st.markdown("- **Job and Environment Satisfaction**: Enhance job and environment satisfaction through initiatives such as recognition programs and improving workplace conditions.")
|
97 |
if years_since_last_promotion > 5:
|
98 |
+
st.markdown("- **Opportunities for Advancement**: Implement a transparent promotion policy and provide opportunities for career advancement.")
|
99 |
if years_with_curr_manager > 5:
|
100 |
+
st.markdown("- **Change in Reporting Structure**: Offer opportunities for a change in reporting structure to prevent stagnation and promote growth.")
|
101 |
if percent_salary_hike < 5:
|
102 |
+
st.markdown("- **Salary and Benefits Adjustment**: Consider adjusting salary and benefits packages to remain competitive and reward employee loyalty.")
|
103 |
if training_times_last_year < 2:
|
104 |
+
st.markdown("- **Employee Development**: Invest in employee development through training programs and continuous learning opportunities.")
|
105 |
if over_time:
|
106 |
+
st.markdown("- **Workload Evaluation**: Evaluate workload distribution and consider implementing measures to prevent overwork, such as workload balancing and flexible scheduling.")
|
107 |
if relationship_satisfaction == 1:
|
108 |
+
st.markdown("- **Positive Work Environment**: Foster positive relationships and a supportive work environment through team-building activities and open communication channels.")
|
109 |
if monthly_income < 5000:
|
110 |
+
st.markdown("- **Compensation Review**: Review compensation structures and adjust salaries to align with industry standards and employee expectations.")
|
111 |
if num_companies_worked > 5:
|
112 |
+
st.markdown("- **Address High Turnover**: Identify reasons for high turnover and address issues related to job stability, career progression, and organizational culture.")
|
113 |
if work_life_balance == 1:
|
114 |
+
st.markdown("- **Work-Life Balance Initiatives**: Promote work-life balance initiatives, such as flexible work arrangements and wellness programs, to support employee well-being.")
|
115 |
|
116 |
# General recommendation for all negative predictions
|
117 |
+
st.markdown("- **Exit Interviews**: Conduct exit interviews to gather feedback and identify areas for improvement in retention strategies.")
|
118 |
|
119 |
if __name__ == "__main__":
|
120 |
main()
|