Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,6 @@ def safe_convert(value, default, min_val, max_val):
|
|
21 |
# Create the main function for the model
|
22 |
def main_func(Department, ChainScale, SupportiveGM, Merit, LearningDevelopment, WorkEnvironment, Engagement, WellBeing):
|
23 |
|
24 |
-
|
25 |
ChainScale_mapping = {
|
26 |
'Luxury': 1,
|
27 |
'Upper Midscale': 2,
|
@@ -37,8 +36,12 @@ def main_func(Department, ChainScale, SupportiveGM, Merit, LearningDevelopment,
|
|
37 |
"Front Office Operations": 4,
|
38 |
"Guest Activities": 5,
|
39 |
}
|
40 |
-
|
41 |
|
|
|
|
|
|
|
|
|
|
|
42 |
LearningDevelopment = safe_convert(LearningDevelopment, 3.0, 1, 5)
|
43 |
SupportiveGM = safe_convert(SupportiveGM, 3.0, 1, 5)
|
44 |
Merit = safe_convert(Merit, 3.0, 1, 5)
|
@@ -46,8 +49,10 @@ def main_func(Department, ChainScale, SupportiveGM, Merit, LearningDevelopment,
|
|
46 |
Engagement = safe_convert(Engagement, 3.0, 1, 5)
|
47 |
WellBeing = safe_convert(WellBeing, 3.0, 1, 5)
|
48 |
|
49 |
-
|
50 |
new_row = pd.DataFrame({
|
|
|
|
|
51 |
'SupportiveGM': [SupportiveGM],
|
52 |
'Merit': [Merit],
|
53 |
'LearningDevelopment': [LearningDevelopment],
|
@@ -85,15 +90,11 @@ def main_func(Department, ChainScale, SupportiveGM, Merit, LearningDevelopment,
|
|
85 |
title = "**Mod 3 Team 5: Employee Turnover Predictor & Interpreter**"
|
86 |
description1 = """
|
87 |
This app evaluates six key factors affecting employee satisfaction—Supportive GM, Merit, Learning & Development, Work Environment, Engagement, and Well-Being—to predict whether an employee is likely to stay with Hilton or leave.
|
88 |
-
|
89 |
The app provides two key outputs:
|
90 |
-
|
91 |
**Predicted Probability**
|
92 |
A likelihood score indicating whether an employee will stay or leave.
|
93 |
-
|
94 |
**SHAP Force Plot**
|
95 |
A dynamic visualization that illustrates how each factor influences the prediction, helping to pinpoint the most impactful drivers of employee retention.
|
96 |
-
|
97 |
Designed for HR teams at both departmental and hotel chain levels, this tool delivers data-driven insights to improve employee experience and retention strategies across Hilton properties.
|
98 |
"""
|
99 |
|
@@ -161,15 +162,15 @@ with gr.Blocks(title=title) as demo:
|
|
161 |
|
162 |
gr.Examples(
|
163 |
[
|
164 |
-
["Guest
|
165 |
-
["Food and Beverage
|
166 |
-
["Housekeeping
|
167 |
-
["Guest
|
168 |
],
|
169 |
[Department, ChainScale, SupportiveGM, Merit, LearningDevelopment, WorkEnvironment, Engagement, WellBeing],
|
170 |
[label, local_plot],
|
171 |
main_func,
|
172 |
cache_examples=True
|
173 |
)
|
174 |
-
|
175 |
-
demo.launch()
|
|
|
21 |
# Create the main function for the model
|
22 |
def main_func(Department, ChainScale, SupportiveGM, Merit, LearningDevelopment, WorkEnvironment, Engagement, WellBeing):
|
23 |
|
|
|
24 |
ChainScale_mapping = {
|
25 |
'Luxury': 1,
|
26 |
'Upper Midscale': 2,
|
|
|
36 |
"Front Office Operations": 4,
|
37 |
"Guest Activities": 5,
|
38 |
}
|
|
|
39 |
|
40 |
+
# Convert inputs
|
41 |
+
Department = department_mapping.get(Department, 1) # Default to "Guest Services"
|
42 |
+
ChainScale = ChainScale_mapping.get(ChainScale, 3) # Default to "Upper Upscale"
|
43 |
+
|
44 |
+
# Ensure numeric input validity
|
45 |
LearningDevelopment = safe_convert(LearningDevelopment, 3.0, 1, 5)
|
46 |
SupportiveGM = safe_convert(SupportiveGM, 3.0, 1, 5)
|
47 |
Merit = safe_convert(Merit, 3.0, 1, 5)
|
|
|
49 |
Engagement = safe_convert(Engagement, 3.0, 1, 5)
|
50 |
WellBeing = safe_convert(WellBeing, 3.0, 1, 5)
|
51 |
|
52 |
+
# Create DataFrame for prediction
|
53 |
new_row = pd.DataFrame({
|
54 |
+
'Department': [Department],
|
55 |
+
'ChainScale': [ChainScale],
|
56 |
'SupportiveGM': [SupportiveGM],
|
57 |
'Merit': [Merit],
|
58 |
'LearningDevelopment': [LearningDevelopment],
|
|
|
90 |
title = "**Mod 3 Team 5: Employee Turnover Predictor & Interpreter**"
|
91 |
description1 = """
|
92 |
This app evaluates six key factors affecting employee satisfaction—Supportive GM, Merit, Learning & Development, Work Environment, Engagement, and Well-Being—to predict whether an employee is likely to stay with Hilton or leave.
|
|
|
93 |
The app provides two key outputs:
|
|
|
94 |
**Predicted Probability**
|
95 |
A likelihood score indicating whether an employee will stay or leave.
|
|
|
96 |
**SHAP Force Plot**
|
97 |
A dynamic visualization that illustrates how each factor influences the prediction, helping to pinpoint the most impactful drivers of employee retention.
|
|
|
98 |
Designed for HR teams at both departmental and hotel chain levels, this tool delivers data-driven insights to improve employee experience and retention strategies across Hilton properties.
|
99 |
"""
|
100 |
|
|
|
162 |
|
163 |
gr.Examples(
|
164 |
[
|
165 |
+
["Guest Services", "Upper Upscale", 4.1, 3.7, 3.9, 4.2, 4.4, 4.3],
|
166 |
+
["Food and Beverage", "Upper Upscale", 3.9, 3.7, 4.1, 4.3, 4.5, 4.4],
|
167 |
+
["Housekeeping", "Upper Upscale", 4.3, 4.0, 4.3, 4.4, 4.5, 4.4],
|
168 |
+
["Guest Services", "Upper Upscale", 5.0, 4.0, 4.3, 4.4, 5.0, 5.0]
|
169 |
],
|
170 |
[Department, ChainScale, SupportiveGM, Merit, LearningDevelopment, WorkEnvironment, Engagement, WellBeing],
|
171 |
[label, local_plot],
|
172 |
main_func,
|
173 |
cache_examples=True
|
174 |
)
|
175 |
+
|
176 |
+
demo.launch()
|