Mpodszus commited on
Commit
5fcb1c0
·
verified ·
1 Parent(s): 27e8059

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -10
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
- with open("h22_xgb_Final.pkl", "rb") as f:
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
- # Convert new_row to DMatrix for XGBoost Booster
33
- dmatrix_new = xgb.DMatrix(new_row)
34
-
35
  # Predict probability for staying (XGBoost Booster returns class probabilities)
36
- prob = loaded_model.predict(dmatrix_new)
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)