class_docstr: Exploring the search space with a cost model
class_docstr_tok: ["Exploring","the","search","space","with","a","cost","model"]
docstr: Use the cost model to predict the estimated performance of configurations and find the top ones for the next round of evaluation
docstr_tok: ["Use","the","cost","model","to","predict","the","estimated","performance","of","configurations","and","find","the","top","ones","for","the","next","round","of","evaluation"]
code: def find_estimated_top_configs(self):
      """Use the cost model to predict the estimated performance of configurations and find the top ones for the next round of evaluation"""
  
      configs = []
  
      for c in self.all_configs:
          flattened_ds_config = flatten(c)
          feature_val = []
          for k, v in flattened_ds_config.items():
              if isinstance(v, numbers.Number):
                  feature_val.append(v)
          configs.append(feature_val)
      # print(configs)
      # TODO the current implementation requires that all configs have the same shape.
      configs = np.array(configs, dtype=np.float32)
      estimates = self.cost_model.predict(configs)
  
      n = len(estimates)
      top_idx = np.argsort(estimates)
      top_idx_ret = (
          top_idx
          if self.metric == AUTOTUNING_METRIC_LATENCY
          else top_idx[::-1][:n]
      )
  
      # top_configs = [self.all_configs[i] for i in top_idx]
  
      return top_idx_ret
  
file_path: H2O/h2o_flexgen/benchmark/third_party/DeepSpeed/deepspeed/autotuning/tuner/model_based_tuner.py
imports: import hjson
  from ..constants import AUTOTUNING, AUTOTUNING_METRIC_PATH
  from .base_tuner import BaseTuner
  from .cost_model import XGBoostCostModel
  from .utils import *
  from ..utils import *
  import numbers
  from ..constants import AUTOTUNING_METRIC_LATENCY
label_desc: Use image node_id 2 for calling the ModelBasedTuner obj's underlying member method code with example usage: obj.find_estimated_top_configs() and returns: top_idx_ret