code: def dropcol_importances(
      model,
      X_train,
      y_train,
      X_valid=None,
      y_valid=None,
      metric=None,
      sample_weights=None,
  ):
      """
      Compute drop-column feature importances for scikit-learn.
  
      Given a classifier or regression in model
      and training X and y data, return a data frame with columns
      Feature and Importance sorted in reverse order by importance.
  
      A clone of model is trained once to get the baseline score and then
      again, once per feature to compute the drop in either the model's .score() output
      or a custom metric callable in the form of metric(model, X_valid, y_valid).
      In case of a custom metric the X_valid and y_valid parameters should be set.
  
      return: A data frame with Feature, Importance columns
  
      SAMPLE CODE
  
      rf = RandomForestRegressor(n_estimators=100, n_jobs=-1)
      X_train, y_train = ..., ...
      rf.fit(X_train, y_train)
      imp = dropcol_importances(rf, X_train, y_train)
      """
      if X_valid is None:
          X_valid = X_train
      if y_valid is None:
          y_valid = y_train
      model_ = clone(model)
      model_.random_state = 999
      model_.fit(X_train, y_train)
      if callable(metric):
          baseline = metric(model_, X_valid, y_valid, sample_weights)
      else:
          baseline = model_.score(X_valid, y_valid, sample_weights)
      imp = []
      for col in X_train.columns:
          model_ = clone(model)
          model_.random_state = 999
          model_.fit(X_train.drop(col, axis=1), y_train)
          if callable(metric):
              s = metric(
                  model_,
                  X_valid.drop(col, axis=1),
                  y_valid,
                  sample_weights,
              )
          else:
              s = model_.score(
                  X_valid.drop(col, axis=1), y_valid, sample_weights
              )
          drop_in_score = baseline - s
          imp.append(drop_in_score)
      imp = np.array(imp)
      I = pd.DataFrame(
          data={"Feature": X_train.columns, "Importance": imp}
      )
      I = I.set_index("Feature")
      I = I.sort_values("Importance", ascending=False)
      return I
  
imports: import pandas
  import numpy
  import matplotlib.pyplot
  import sklearn
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.ensemble import RandomForestRegressor
  from distutils.version import LooseVersion
  from sklearn.model_selection import cross_val_score
  from sklearn.base import clone
  from sklearn.metrics import r2_score
  from sklearn.metrics import f1_score
  from sklearn.preprocessing import LabelEncoder
  from scipy import stats
  from pandas.api.types import is_numeric_dtype
  from matplotlib.colors import ListedColormap
  from matplotlib.ticker import FormatStrFormatter
  from copy import copy
  import warnings
  import tempfile
  from os import getpid, makedirs
label_desc: Use image node_id 7 for calling a global function with example usage: dropcol_importances(model, X_train, y_train, X_valid, y_valid, metric, sample_weights) and returns: I