code: def rf(df_1, y, json_file, trained=True):
      """
      random forest  training function
      :param df_1: dataframe
      :param y: is the target column
      :trained: whether the model is already trained or not
      :return compiled random forest model
      """
  
      n_estimators = 100
      criterion = "gini"
      max_depth = None
      max_features = "auto"
  
      if "params" in json_file:
          parameters = json_file["params"]
          if "n_estimators" in parameters:
              n_estimators = parameters["n_estimators"]
          if "criterion" in parameters:
              criterion = parameters["criterion"]
          if "max_depth" in parameters:
              max_depth = parameters["max_depth"]
          if "max_features" in parameters:
              max_features = parameters["max_features"]
  
      clf = RandomForestClassifier(
          n_estimators=n_estimators,
          criterion=criterion,
          max_depth=max_depth,
          max_features=max_features,
      )
      if trained:
          clf.fit(df_1, y)
      return clf
  
imports: from sklearn.tree import DecisionTreeClassifier
  from sklearn import svm
  import numpy
  from sklearn.linear_model import SGDClassifier
  from sklearn.neighbors import KNeighborsClassifier
  from sklearn.ensemble import GradientBoostingClassifier
  from sklearn.ensemble import AdaBoostClassifier
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.neural_network import MLPClassifier
  from sklearn.metrics import accuracy_score
  from sklearn.ensemble import ExtraTreesClassifier
  from sklearn.model_selection import GridSearchCV, RandomizedSearchCV
  import warnings
label_desc: Use image node_id 8 for calling a global function with example usage: rf(df_1, y, json_file, trained) and returns: clf