Upload 3 files
Browse files- Hilton app_1.py +109 -0
- cat.joblib +3 -0
- requirements.txt +6 -0
Hilton app_1.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# coding: utf-8
|
| 3 |
+
|
| 4 |
+
# In[2]:
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
import joblib
|
| 8 |
+
import pandas as pd
|
| 9 |
+
import gradio as gr
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# In[11]:
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
model = joblib.load("cat.joblib")
|
| 16 |
+
|
| 17 |
+
FEATURES = [
|
| 18 |
+
"Engagement",
|
| 19 |
+
"SupportiveGM",
|
| 20 |
+
"ManagementLevel",
|
| 21 |
+
"WellBeing",
|
| 22 |
+
"Voice",
|
| 23 |
+
"DecisionAutonomy",
|
| 24 |
+
"AppreciatedAtWork",
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
def predict_focus_level3(
|
| 28 |
+
Engagement,
|
| 29 |
+
SupportiveGM,
|
| 30 |
+
WellBeing,
|
| 31 |
+
Voice,
|
| 32 |
+
DecisionAutonomy,
|
| 33 |
+
AppreciatedAtWork
|
| 34 |
+
):
|
| 35 |
+
|
| 36 |
+
results = []
|
| 37 |
+
|
| 38 |
+
# Predict for all levels (for comparison)
|
| 39 |
+
for mgmt in [1,2,3,4]:
|
| 40 |
+
X = pd.DataFrame([[
|
| 41 |
+
Engagement,
|
| 42 |
+
SupportiveGM,
|
| 43 |
+
mgmt,
|
| 44 |
+
WellBeing,
|
| 45 |
+
Voice,
|
| 46 |
+
DecisionAutonomy,
|
| 47 |
+
AppreciatedAtWork,
|
| 48 |
+
]], columns=FEATURES)
|
| 49 |
+
|
| 50 |
+
p = float(model.predict_proba(X)[0,1])
|
| 51 |
+
|
| 52 |
+
results.append({
|
| 53 |
+
"ManagementLevel": mgmt,
|
| 54 |
+
"Prob_HighIntent": p
|
| 55 |
+
})
|
| 56 |
+
|
| 57 |
+
df = pd.DataFrame(results)
|
| 58 |
+
|
| 59 |
+
# ⭐ Focus result
|
| 60 |
+
level3_prob = df.loc[df["ManagementLevel"]==3,"Prob_HighIntent"].iloc[0]
|
| 61 |
+
|
| 62 |
+
# Bar chart comparison
|
| 63 |
+
fig, ax = plt.subplots()
|
| 64 |
+
colors = ["gray","gray","orange","gray"] # highlight level 3
|
| 65 |
+
ax.bar(df["ManagementLevel"], df["Prob_HighIntent"], color=colors)
|
| 66 |
+
ax.set_xlabel("Management Level")
|
| 67 |
+
ax.set_ylabel("Probability High Intent")
|
| 68 |
+
ax.set_title("Management Level 3 Highlighted")
|
| 69 |
+
|
| 70 |
+
headline = f"Predicted probability of HIGH intent to stay for Management Level 3: {level3_prob:.2%}"
|
| 71 |
+
|
| 72 |
+
return headline, df, fig
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
with gr.Blocks() as demo:
|
| 76 |
+
gr.Markdown("# Intent to Stay — Management Level 3 Focus")
|
| 77 |
+
|
| 78 |
+
with gr.Row():
|
| 79 |
+
with gr.Column():
|
| 80 |
+
Engagement = gr.Slider(1,5,step=1,label="Engagement")
|
| 81 |
+
SupportiveGM = gr.Slider(1,5,step=1,label="Supportive GM")
|
| 82 |
+
WellBeing = gr.Slider(1,5,step=1,label="Well Being")
|
| 83 |
+
Voice = gr.Slider(1,5,step=1,label="Voice")
|
| 84 |
+
DecisionAutonomy = gr.Slider(1,5,step=1,label="Decision Autonomy")
|
| 85 |
+
AppreciatedAtWork = gr.Slider(1,5,step=1,label="Appreciated At Work")
|
| 86 |
+
|
| 87 |
+
btn = gr.Button("Predict")
|
| 88 |
+
|
| 89 |
+
with gr.Column():
|
| 90 |
+
headline = gr.Markdown()
|
| 91 |
+
table = gr.Dataframe(label="All Management Levels")
|
| 92 |
+
plot = gr.Plot()
|
| 93 |
+
|
| 94 |
+
btn.click(
|
| 95 |
+
fn=predict_focus_level3,
|
| 96 |
+
inputs=[
|
| 97 |
+
Engagement,
|
| 98 |
+
SupportiveGM,
|
| 99 |
+
WellBeing,
|
| 100 |
+
Voice,
|
| 101 |
+
DecisionAutonomy,
|
| 102 |
+
AppreciatedAtWork
|
| 103 |
+
],
|
| 104 |
+
outputs=[headline, table, plot]
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
demo.launch(share=True)
|
| 109 |
+
|
cat.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be1987e9f56cdf5871e6e6dcbd6b4cec5aef9a719c1475a87447a47f6b13b558
|
| 3 |
+
size 4374820
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
pandas
|
| 3 |
+
joblib
|
| 4 |
+
catboost
|
| 5 |
+
scikit-learn
|
| 6 |
+
matplotlib
|