docstr: Return the k most similar datasets with respect to self.metric
  
  Parameters
  ----------
  x : pandas.Series
      A pandas Series object with the metafeatures for one dataset
  
  k : int
      Number of k nearest datasets which are returned. If k == -1,
      return all dataset sorted by similarity.
  
  return_distance : bool, optional. Defaults to False
      If true, distances to the new dataset will be returned.
  
  Returns
  -------
  list
      Names of the most similar datasets, sorted by similarity
  
  list
      Sorted distances. Only returned if return_distances is set to True.
docstr_tok: ["Return","the","k","most","similar","datasets","with","respect","to","self.metric","Parameters","--","--","--","--","--","x",":","pandas.Series","A","pandas","Series","object","with","the","metafeatures","for","one","dataset","k",":","int","Number","of","k","nearest","datasets","which","are","returned",".","If","k","==","-1",",","return","all","dataset","sorted","by","similarity",".","return_distance",":","bool",",","optional",".","Defaults","to","False","If","true",",","distances","to","the","new","dataset","will","be","returned",".","Returns","--","--","--","-","list","Names","of","the","most","similar","datasets",",","sorted","by","similarity","list","Sorted","distances",".","Only","returned","if","return_distances","is","set","to","True","."]
code: def kNearestDatasets(self, x, k=1, return_distance=False):
      """Return the k most similar datasets with respect to self.metric
  
      Parameters
      ----------
      x : pandas.Series
          A pandas Series object with the metafeatures for one dataset
  
      k : int
          Number of k nearest datasets which are returned. If k == -1,
          return all dataset sorted by similarity.
  
      return_distance : bool, optional. Defaults to False
          If true, distances to the new dataset will be returned.
  
      Returns
      -------
      list
          Names of the most similar datasets, sorted by similarity
  
      list
          Sorted distances. Only returned if return_distances is set to True.
      """
      assert type(x) == pd.Series
      if k < -1 or k == 0:
          raise ValueError(
              "Number of neighbors k cannot be zero or negative."
          )
      elif k == -1:
          k = self.num_datasets
  
      X_train = self.scaler.transform(self.metafeatures)
      x = x.values.reshape((1, -1))
      x = self.scaler.transform(x)
      self._nearest_neighbors.fit(X_train)
      distances, neighbor_indices = self._nearest_neighbors.kneighbors(
          x, n_neighbors=k, return_distance=True
      )
  
      assert k == neighbor_indices.shape[1]
  
      return_value = [
          self.metafeatures.index[i]
          # Neighbor indices is 2d, each row is the indices for one
          # dataset in x.
          for i in neighbor_indices[0]
      ]
  
      if return_distance is False:
          return return_value
      else:
          return return_value, distances[0]
  
file_path: auto-sklearn/autosklearn/metalearning/metalearning/kNearestDatasets/kND.py
imports: import numpy
  import pandas
  import sklearn.utils
  from sklearn.neighbors import NearestNeighbors
  from sklearn.preprocessing import MinMaxScaler
label_desc: Use image node_id 3 for calling the KNearestDatasets obj's underlying member method code with example usage: obj.kNearestDatasets(x, k, return_distance) and returns: return_value, return_value,  distances