Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,7 @@ import numpy as np
|
|
8 |
import matplotlib.pyplot as plt
|
9 |
|
10 |
# Load the XGBoost model from Pickle (Corrected: Using 'rb' mode)
|
11 |
-
|
12 |
-
raw_model = pickle.load(f)
|
13 |
-
|
14 |
-
# Restore the Booster from the raw format
|
15 |
-
loaded_model = xgb.Booster()
|
16 |
-
loaded_model.load_model(raw_model)
|
17 |
|
18 |
# Setup SHAP Explainer for XGBoost
|
19 |
explainer = shap.TreeExplainer(loaded_model)
|
@@ -29,11 +24,9 @@ def main_func(SupportiveGM, Merit, LearningDevelopment, WorkEnvironment, Engagem
|
|
29 |
'WellBeing': WellBeing
|
30 |
}, orient='index').transpose()
|
31 |
|
32 |
-
|
33 |
-
dmatrix_new = xgb.DMatrix(new_row)
|
34 |
-
|
35 |
# Predict probability for staying (XGBoost Booster returns class probabilities)
|
36 |
-
prob = loaded_model.
|
37 |
|
38 |
# Compute SHAP values
|
39 |
shap_values = explainer(new_row)
|
|
|
8 |
import matplotlib.pyplot as plt
|
9 |
|
10 |
# Load the XGBoost model from Pickle (Corrected: Using 'rb' mode)
|
11 |
+
loaded_model = pickle.load(open("h22_xgb_Final(2).pkl", 'rb'))
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Setup SHAP Explainer for XGBoost
|
14 |
explainer = shap.TreeExplainer(loaded_model)
|
|
|
24 |
'WellBeing': WellBeing
|
25 |
}, orient='index').transpose()
|
26 |
|
27 |
+
|
|
|
|
|
28 |
# Predict probability for staying (XGBoost Booster returns class probabilities)
|
29 |
+
prob = loaded_model.predict_proba(new_row)
|
30 |
|
31 |
# Compute SHAP values
|
32 |
shap_values = explainer(new_row)
|