code: def plot_importance(model, partition):
      r"""Display scikit-learn feature importances.
  
      Parameters
      ----------
      model : alphapy.Model
          The model object with plotting specifications.
      partition : alphapy.Partition
          Reference to the dataset.
  
      Returns
      -------
      None : None
  
      References
      ----------
  
      http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html
  
      """
  
      logger.info("Generating Feature Importance Plots")
      plot_dir = get_plot_directory(model)
      pstring = datasets[partition]
  
      # For each algorithm that has importances, generate the plot.
  
      n_top = 20
  
      for algo in model.algolist:
          logger.info("Feature Importances for Algorithm: %s", algo)
          try:
              # get feature importances
              importances = np.array(model.importances[algo])
              imp_flag = True
          except:
              imp_flag = False
          if imp_flag:
              # sort the importances by index
              indices = np.argsort(importances)[::-1]
              # get feature names
              feature_names = np.array(model.fnames_algo[algo])
              n_features = len(feature_names)
              # log the feature ranking
              logger.info("Feature Ranking:")
              n_min = min(n_top, n_features)
              for i in range(n_min):
                  logger.info(
                      "%d. %s (%f)"
                      % (
                          i + 1,
                          feature_names[indices[i]],
                          importances[indices[i]],
                      )
                  )
              # plot the feature importances
              title = BSEP.join(
                  [algo, "Feature Importances [", pstring, "]"]
              )
              plt.figure()
              plt.title(title)
              plt.barh(range(n_min), importances[indices][:n_min][::-1])
              plt.yticks(
                  range(n_min), feature_names[indices][:n_min][::-1]
              )
              plt.ylim([-1, n_min])
              plt.xlabel("Relative Importance")
              # save the plot
              tag = USEP.join([pstring, algo])
              write_plot(
                  "matplotlib", plt, "feature_importance", tag, plot_dir
              )
          else:
              logger.info("No Feature Importances for %s" % algo)
  
imports: from alphapy.estimators import get_estimators
  from alphapy.globals import BSEP, PSEP, SSEP, USEP
  from alphapy.globals import ModelType
  from alphapy.globals import Partition, datasets
  from alphapy.globals import Q1, Q3
  from alphapy.utilities import remove_list_items
  from bokeh.plotting import figure, show, output_file
  import itertools
  import logging
  import math
  import matplotlib
  import matplotlib.pyplot
  from mpl_toolkits.mplot3d import Axes3D
  import numpy
  import pandas
  from scipy import interp
  import seaborn
  from sklearn.calibration import calibration_curve
  from sklearn.inspection import partial_dependence
  from sklearn.inspection import plot_partial_dependence
  from sklearn.metrics import auc
  from sklearn.metrics import confusion_matrix
  from sklearn.metrics import roc_curve
  from sklearn.model_selection import cross_val_score
  from sklearn.model_selection import learning_curve
  from sklearn.model_selection import StratifiedKFold
  from sklearn.model_selection import train_test_split
  from sklearn.model_selection import validation_curve
  from sklearn.utils.multiclass import unique_labels
label_desc: Use image node_id 6 for calling a global function with example usage: plot_importance(model, partition) without return types