class_docstr: Class Feature Interpreter.
  
  The class is used to generate the following information:
      - feature distribution
      - feature correlation
      - feature importance ranking for a trained model
docstr: Internal function to generate feature ranking using shap value
  
  Args:
      trained_model: model obj, the trained model object
      train_x: numpy.dnarray, training data
      mode: str, classification (default) or regression
  
  Returns:
      A list of tuple (feature name, feature importance score) in descending order
docstr_tok: ["Internal","function","to","generate","feature","ranking","using","shap","value","Args",":","trained_model",":","model","obj",",","the","trained","model","object","train_x",":","numpy.dnarray",",","training","data","mode",":","str",",","classification","(","default",")","or","regression","Returns",":","A","list","of","tuple","(","feature","name",",","feature","importance","score",")","in","descending","order"]
code: def _get_ranking_by_shap(
      self, trained_model, train_x, mode: str = MODE.CLASSIFICATION
  ) -> List[Tuple[str, float]]:
      """
      Internal function to generate feature ranking using shap value
  
      Args:
          trained_model: model obj, the trained model object
          train_x: numpy.dnarray, training data
          mode: str, classification (default) or regression
  
      Returns:
          A list of tuple (feature name, feature importance score) in descending order
      """
      feature_values = self.get_feature_shap_values(
          trained_model=trained_model, train_x=train_x, mode=mode
      )
      sum_importance = numpy.zeros(len(self._feature_names))
      shap_values = numpy.array(
          [v for _, v in feature_values]
      ).transpose()
      for ind in range(len(shap_values)):
          global_shap_values = numpy.abs(shap_values[ind]).mean(axis=0)
          sum_importance += global_shap_values
      scores = sum_importance / len(shap_values)
      feature_importance = {
          key: value
          for key, value in list(
              zip(self._feature_names, scores.tolist())
          )
      }
      feature_importance = sorted(
          feature_importance.items(),
          key=operator.itemgetter(1),
          reverse=True,
      )
  
      return feature_importance
  
imports: import operator
  import warnings
  import numpy
  import pandas
  from scipy import stats
  from typing import List, Dict, Tuple
  import shap
  from xai import ALG, MODE
  from xai.data.constants import DATATYPE
  from xai.data.explorer.data_analyzer_suite import DataAnalyzerSuite
  from xai.model.interpreter.exceptions import InconsistentSize, TrainingDataNotProvided
  from xai.model.interpreter.exceptions import UnsupportedMethodType
label_desc: Use image node_id 10 for calling the FeatureInterpreter obj's underlying member method code with example usage: obj._get_ranking_by_shap(trained_model, train_x, mode) and returns: feature_importance