class_docstr: Base class for doing parameter search.
  
  Parameters
  ----------------
  model: :obj:`cornac.models.Recommender`, required
      Base recommender model to be tuned.
  
  space: list, required
      Parameter space to be searched on.
      It's a list of :obj:`cornac.hyperopt.SearchDomain`.
  
  metric: :obj:`cornac.metrics.RatingMetric` or :obj:`cornac.metrics.RankingMetric`, required
      Scoring metric to measure the performance and rank the parameter settings.
  
  eval_method: :obj:`cornac.eval_methods.BaseMethod`, required
      Evaluation method is being used. 
      
  name: str, default: 'BaseSearch'
      The name of the searching strategy.
      
class_docstr_tok: ["Base","class","for","doing","parameter","search",".","Parameters","--","--","--","--","--","--","--","--","model",":",":","obj",":","`","cornac.models.Recommender","`",",","required","Base","recommender","model","to","be","tuned",".","space",":","list",",","required","Parameter","space","to","be","searched","on",".","It","'s","a","list","of",":","obj",":","`","cornac.hyperopt.SearchDomain","`",".","metric",":",":","obj",":","`","cornac.metrics.RatingMetric","`","or",":","obj",":","`","cornac.metrics.RankingMetric","`",",","required","Scoring","metric","to","measure","the","performance","and","rank","the","parameter","settings",".","eval_method",":",":","obj",":","`","cornac.eval_methods.BaseMethod","`",",","required","Evaluation","method","is","being","used",".","name",":","str",",","default",":","'BaseSearch'","The","name","of","the","searching","strategy","."]
docstr: Doing hyper-parameter search
docstr_tok: ["Doing","hyper-parameter","search"]
code: def fit(self, train_set, val_set=None):
      """Doing hyper-parameter search"""
      assert val_set is not None
      Recommender.fit(self, train_set, val_set)
  
      param_set = self._build_param_set()
      compare_op = np.greater if self.metric.higher_better else np.less
      self.best_score = -np.inf if self.metric.higher_better else np.inf
      self.best_model = None
      self.best_params = None
  
      # this can be parallelized if needed
      # keep it simple because multimodal algorithms are usually resource-hungry
      for params in param_set:
          if self.verbose:
              print("Evaluating: {}".format(params))
  
          model = self.model.clone(params).fit(train_set, val_set)
  
          if isinstance(self.metric, RatingMetric):
              score = rating_eval(model, [self.metric], val_set)[0][0]
          else:
              score = ranking_eval(
                  model,
                  [self.metric],
                  train_set,
                  val_set,
                  rating_threshold=self.eval_method.rating_threshold,
                  exclude_unknowns=self.eval_method.exclude_unknowns,
                  verbose=False,
              )[0][0]
  
          if compare_op(score, self.best_score):
              self.best_score = score
              self.best_model = model
              self.best_params = params
  
          del model
  
      if self.verbose:
          print("Best parameter settings: {}".format(self.best_params))
          print("{} = {:.4f}".format(self.metric.name, self.best_score))
  
      return self
  
imports: import numpy
  from itertools import product
  from .models import Recommender
  from .metrics import RatingMetric, RankingMetric
  from .eval_methods import rating_eval, ranking_eval
  from .utils import get_rng
label_desc: Use image node_id 3 for calling the BaseSearch obj's underlying member method code with example usage: obj.fit(train_set, val_set) and returns: self