code: def create_predict_spearman_rank(metafeatures, experiments, iterator):
      X = []
      Y = []
      Y_names = []
      # Calculate the pairwise ranks between datasets
      dataset_names = [name for name in metafeatures.index]
      cross_product = []
  
      if iterator == "combination":
          for cross in itertools.combinations_with_replacement(
              dataset_names, r=2
          ):
              cross_product.append(cross)
      elif iterator == "permutation":
          for cross in itertools.permutations(dataset_names, r=2):
              cross_product.append(cross)
      else:
          raise NotImplementedError(iterator)
      logging.info(
          "Create spearman rank dataset without CV data and %s",
          iterator,
      )
      logging.info("Using %d datasets", len(dataset_names))
      logging.info(
          "This will results in %d training points", len(cross_product)
      )
  
      # Create inputs and targets
      for cross in cross_product:
          name = "%s_%s" % (cross[0], cross[1])
  
          mf_1 = metafeatures.loc[cross[0]]
          mf_2 = metafeatures.loc[cross[1]]
          assert mf_1.dtype == np.float64
          assert mf_2.dtype == np.float64
          x = np.hstack((mf_1, mf_2))
          columns = metafeatures.columns.values
          index = np.hstack(("0_" + columns, "1_" + columns))
          x = pd.Series(data=x, name=name, index=index)
          X.append(x)
  
          experiments_1 = experiments[cross[0]]
          experiments_2 = experiments[cross[1]]
          assert len(experiments_1) == len(experiments_2), name
  
          responses_1 = np.zeros((len(experiments_1)), dtype=np.float64)
          responses_2 = np.zeros((len(experiments_1)), dtype=np.float64)
  
          for idx, zipped in enumerate(
              zip(
                  sorted(
                      experiments_1, key=lambda t: str(t.configuration)
                  ),
                  sorted(
                      experiments_2, key=lambda t: str(t.configuration)
                  ),
              )
          ):
              # Test if the order of the params is the same
              exp_1, exp_2 = zipped
              print(exp_1.configuration, exp_2.configuration)
              assert exp_1.configuration == exp_2.configuration, (
                  experiments_1,
                  experiments_2,
              )
              responses_1[idx] = (
                  exp_1.result if np.isfinite(exp_1.result) else 1
              )
              responses_2[idx] = (
                  exp_2.result if np.isfinite(exp_2.result) else 1
              )
  
          rho, p = scipy.stats.spearmanr(responses_1, responses_2)
          # rho, p = scipy.stats.kendalltau(responses_1, responses_2)
          if not np.isfinite(rho):
              rho = 0
  
          Y.append(rho)
          Y_names.append(name)
  
      X = pd.DataFrame(X)
      Y = pd.Series(Y, index=Y_names)
      logging.info("Metafeatures %s", metafeatures.shape)
      logging.info("X.shape %s", X.shape)
      logging.info("Y.shape %s", Y.shape)
      assert X.shape == (
          len(cross_product),
          metafeatures.shape[1] * 2,
      ), (
          X.shape,
          (len(cross), metafeatures.shape[1] * 2),
      )
      assert Y.shape == (len(cross_product),)
      # train sklearn regressor (tree) with 10fold CV
      indices = range(len(X))
      np_rs = np.random.RandomState(42)
      np_rs.shuffle(indices)
      X = X.iloc[indices]
      Y = Y.iloc[indices]
      return X, Y
  
file_path: auto-sklearn/autosklearn/metalearning/metalearning/create_datasets.py
imports: import itertools
  import logging
  import numpy
  import pandas
  import scipy.stats
label_desc: Use image node_id 2 for calling a global function with example usage: create_predict_spearman_rank(metafeatures, experiments, iterator) and returns: X,  Y