code: def _shap_importances(model, X):
      """Extract feature importances from fitted boosting models
      using TreeExplainer from shap.
  
      Returns
      -------
      array of feature importances.
      """
  
      explainer = TreeExplainer(
          model, feature_perturbation="tree_path_dependent"
      )
      coefs = explainer.shap_values(X)
  
      if isinstance(coefs, list):
          coefs = list(map(lambda x: np.abs(x).mean(0), coefs))
          coefs = np.sum(coefs, axis=0)
      else:
          coefs = np.abs(coefs).mean(0)
  
      return coefs
  
file_path: shap-hypetune/shaphypetune/utils.py
imports: import random
  import numpy
  from itertools import product
  from shap import TreeExplainer
label_desc: Use image node_id 2 for calling a global function with example usage: _shap_importances(model, X) and returns: coefs