code: def xgboost_shap(self, model, X):
      # explain the model's predictions using SHAP
      # (same syntax works for LightGBM, CatBoost, scikit-learn and spark models)
      explainer = shap.TreeExplainer(model)
      shap_values = explainer.shap_values(X)
  
      pd_shap = pd.DataFrame(shap_values)
      all_columns = list(X.columns)
  
      shap_columns = []
  
      for i in all_columns:
          shap_columns.append(i + "_impact")
  
      pd_shap.columns = shap_columns
  
      Y = X.copy()
      for c in shap_columns:
          Y[c] = list(pd_shap[c])
  
      return Y, explainer
  
file_path: explainx/lib/calculate_shap.py
imports: from imports import *
  from rescale_numeric_feature import *
label_desc: Use image node_id 2 for calling the calculate_shap obj's underlying member method code with example usage: obj.xgboost_shap(model, X) and returns: Y,  explainer