code: def oob_dependences(rf, X_train, n_samples=5000):
      """
      Given a random forest model, rf, and training observation independent
      variables in X_train (a dataframe), compute the OOB R^2 score using each var
      as a dependent variable. We retrain rf for each var.    Only numeric columns are considered.
  
      By default, sample up to 5000 observations to compute feature dependencies.
  
      :return: Return a DataFrame with Feature/Dependence values for each variable. Feature is the dataframe index.
      """
      numcols = [
          col for col in X_train if is_numeric_dtype(X_train[col])
      ]
  
      X_train = sample_rows(X_train, n_samples)
  
      df_dep = pd.DataFrame(columns=["Feature", "Dependence"])
      df_dep = df_dep.set_index("Feature")
      for col in numcols:
          X, y = X_train.drop(col, axis=1), X_train[col]
          rf.fit(X, y)
          df_dep.loc[col] = rf.oob_score_
      df_dep = df_dep.sort_values("Dependence", ascending=False)
      return df_dep
  
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 17 for calling a global function with example usage: oob_dependences(rf, X_train, n_samples) and returns: df_dep