class_docstr: PUBDEV-2967: gridsearch sorting metric with cross-validation.
  
  This class is created to test that when cross-validation is enabled, the gridsearch models are returned sorted
  according to the cross-validation metrics.
  
  Test Descriptions:
      a. grab all truely griddable parameters and randomly or manually set the parameter values.
      b. Next, build H2O random forest models using grid search.  No model is built for bad hyper-parameters
         values.  We should instead get a warning/error message printed out.
      c. Check and make sure that the models are returned sorted with the correct cross-validation metrics.
  
  Note that for hyper-parameters containing all legal parameter names and parameter value lists with legal
  and illegal values, grid-models should be built for all combinations of legal parameter values.  For
  illegal parameter values, a warning/error message should be printed out to warn the user but the
  program should not throw an exception;
  
  We will re-use the dataset generation methods for GLM.  There will be only one data set for classification.
class_docstr_tok: ["PUBDEV-2967",":","gridsearch","sorting","metric","with","cross-validation",".","This","class","is","created","to","test","that","when","cross-validation","is","enabled",",","the","gridsearch","models","are","returned","sorted","according","to","the","cross-validation","metrics",".","Test","Descriptions",":","a.","grab","all","truely","griddable","parameters","and","randomly","or","manually","set","the","parameter","values",".","b",".","Next",",","build","H2O","random","forest","models","using","grid","search",".","No","model","is","built","for","bad","hyper-parameters","values",".","We","should","instead","get","a","warning\/error","message","printed","out",".","c.","Check","and","make","sure","that","the","models","are","returned","sorted","with","the","correct","cross-validation","metrics",".","Note","that","for","hyper-parameters","containing","all","legal","parameter","names","and","parameter","value","lists","with","legal","and","illegal","values",",","grid-models","should","be","built","for","all","combinations","of","legal","parameter","values",".","For","illegal","parameter","values",",","a","warning\/error","message","should","be","printed","out","to","warn","the","user","but","the","program","should","not","throw","an","exception",";","We","will","re-use","the","dataset","generation","methods","for","GLM",".","There","will","be","only","one","data","set","for","classification","."]
docstr: This function performs all initializations necessary:
  load the data sets and set the training set indices and response column index
docstr_tok: ["This","function","performs","all","initializations","necessary",":","load","the","data","sets","and","set","the","training","set","indices","and","response","column","index"]
code: def setup_data(self):
      """
      This function performs all initializations necessary:
      load the data sets and set the training set indices and response column index
      """
  
      # create and clean out the sandbox directory first
      self.sandbox_dir = pyunit_utils.make_Rsandbox_dir(
          self.current_dir, self.test_name, True
      )
  
      # preload data sets
      self.training1_data = h2o.import_file(
          path=pyunit_utils.locate(self.training1_filename)
      )
  
      # set data set indices for predictors and response
      self.y_index = self.training1_data.ncol - 1
      self.x_indices = list(range(self.y_index))
  
      # set response to be categorical for classification tasks
      self.training1_data[self.y_index] = (
          self.training1_data[self.y_index].round().asfactor()
      )
  
      # save the training data files just in case the code crashed.
      pyunit_utils.remove_csv_files(
          self.current_dir,
          ".csv",
          action="copy",
          new_dir_path=self.sandbox_dir,
      )
  
file_path: h2o-3/h2o-py/dynamic_tests/testdir_algos/rf/pyunit_rf_gridsearch_sorting_metrics.py
imports: import sys
  import random
  import os
  from builtins import range
  import time
  import json
  import h2o
  from tests import pyunit_utils
  from h2o.estimators.random_forest import H2ORandomForestEstimator
  from h2o.grid.grid_search import H2OGridSearch
label_desc: Use image node_id 2 for calling the Test_rf_gridsearch_sorting_metrics obj's underlying member method code with example usage: obj.setup_data() without return types