docstr: Fit the Nearest Neighbor model.
  
  Parameters
  ----------
  metafeatures : pandas.DataFrame
      A pandas dataframe. Each row represents a dataset, each column a
      metafeature.
  runs : dict
      Dictionary containing a list of runs for each dataset.
docstr_tok: ["Fit","the","Nearest","Neighbor","model",".","Parameters","--","--","--","--","--","metafeatures",":","pandas.DataFrame","A","pandas","dataframe",".","Each","row","represents","a","dataset",",","each","column","a","metafeature",".","runs",":","dict","Dictionary","containing","a","list","of","runs","for","each","dataset","."]
code: def fit(self, metafeatures, runs):
      """Fit the Nearest Neighbor model.
  
      Parameters
      ----------
      metafeatures : pandas.DataFrame
          A pandas dataframe. Each row represents a dataset, each column a
          metafeature.
      runs : dict
          Dictionary containing a list of runs for each dataset.
      """
      assert isinstance(metafeatures, pd.DataFrame)
      assert metafeatures.values.dtype in (np.float32, np.float64)
      assert np.isfinite(metafeatures.values).all()
      assert isinstance(runs, pd.DataFrame)
      assert runs.shape[1] == metafeatures.shape[0], (
          runs.shape[1],
          metafeatures.shape[0],
      )
  
      self.metafeatures = metafeatures
      self.runs = runs
      self.num_datasets = runs.shape[1]
  
      # Fit the metafeatures for scaler
      self.scaler.fit(self.metafeatures)
  
      # for each dataset, sort the runs according to their result
      best_configuration_per_dataset = {}
      for dataset_name in runs:
          if not np.isfinite(runs[dataset_name]).any():
              best_configuration_per_dataset[dataset_name] = None
          else:
              configuration_idx = runs[dataset_name].index[
                  np.nanargmin(runs[dataset_name].values)
              ]
              best_configuration_per_dataset[
                  dataset_name
              ] = configuration_idx
  
      self.best_configuration_per_dataset = (
          best_configuration_per_dataset
      )
  
      if callable(self.metric):
          self._metric = self.metric
          self._p = 0
      elif self.metric.lower() == "l1":
          self._metric = "minkowski"
          self._p = 1
      elif self.metric.lower() == "l2":
          self._metric = "minkowski"
          self._p = 2
      else:
          raise ValueError(self.metric)
  
      self._nearest_neighbors = NearestNeighbors(
          n_neighbors=self.num_datasets,
          radius=None,
          algorithm="brute",
          leaf_size=30,
          metric=self._metric,
          p=self._p,
          metric_params=self.metric_params,
      )
  
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 2 for calling the KNearestDatasets obj's underlying member method code with example usage: obj.fit(metafeatures, runs) without return types