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: Get feature importance ranking
  
  Args:
      trained_model: model obj, the trained model object
      train_x: numpy.dnarray, training data
      method: str, pre-defined method for feature importance
  
  Returns:
      A list of tuple (feature name, feature importance score) in descending order
docstr_tok: ["Get","feature","importance","ranking","Args",":","trained_model",":","model","obj",",","the","trained","model","object","train_x",":","numpy.dnarray",",","training","data","method",":","str",",","pre-defined","method","for","feature","importance","Returns",":","A","list","of","tuple","(","feature","name",",","feature","importance","score",")","in","descending","order"]
code: def get_feature_importance_ranking(
      self,
      trained_model,
      train_x: numpy.ndarray = None,
      method="default",
      mode: str = MODE.CLASSIFICATION,
  ) -> List[Tuple[str, float]]:
      """
      Get feature importance ranking
  
      Args:
          trained_model: model obj, the trained model object
          train_x: numpy.dnarray, training data
          method: str, pre-defined method for feature importance
  
      Returns:
          A list of tuple (feature name, feature importance score) in descending order
  
      """
      if method == "default":
          scores = trained_model.feature_importances_
          if len(scores) != len(self._feature_names):
              raise InconsistentSize(
                  "scores",
                  "feature_names",
                  len(scores),
                  len(self._feature_names),
              )
          else:
              feature_importance = {
                  key: value
                  for key, value in list(
                      zip(self._feature_names, scores)
                  )
              }
              feature_importance = sorted(
                  feature_importance.items(),
                  key=operator.itemgetter(1),
                  reverse=True,
              )
              return feature_importance
  
      else:
          if (
              method
              not in FeatureInterpreter.SUPPORTED_FEATURE_IMPORTANCE_TYPES
          ):
              raise UnsupportedMethodType(method)
          if train_x is None:
              raise TrainingDataNotProvided
  
          if method == ALG.SHAP:
              return self._get_ranking_by_shap(
                  trained_model, train_x, mode
              )
  
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 8 for calling the FeatureInterpreter obj's underlying member method code with example usage: obj.get_feature_importance_ranking(trained_model, train_x, method, mode) and returns: feature_importance, self