class_docstr: Model hyper-parameters tuner.
  
   `model.params.hyper_space` reprensents the model's hyper-parameters
   search space, which is the cross-product of individual hyper parameter's
   hyper space. When a `Tuner` builds a model, for each hyper parameter in
   `model.params`, if the hyper-parameter has a hyper-space, then a sample
   will be taken in the space. However, if the hyper-parameter does not
   have a hyper-space, then the default value of the hyper-parameter will
   be used.
  
   See `tutorials/model_tuning.ipynb` for a detailed walkthrough on usage.
  
   :param params: A completed parameter table to tune. Usually `model.params`
       of the desired model to tune. `params.completed()` should be `True`.
   :param train_data: Training data to use. Either a preprocessed `DataPack`,
       or a `DataGenerator`.
   :param test_data: Testing data to use. A preprocessed `DataPack`.
   :param fit_kwargs: Extra keyword arguments to pass to `fit`.
       (default: `dict(epochs=10, verbose=0)`)
   :param evaluate_kwargs: Extra keyword arguments to pass to `evaluate`.
   :param metric: Metric to tune upon. Must be one of the metrics in
       `model.params['task'].metrics`. (default: the first metric in
       `params.['task'].metrics`.
   :param mode: Either `maximize` the metric or `minimize` the metric.
       (default: 'maximize')
   :param num_runs: Number of runs. Each run takes a sample in
       `params.hyper_space` and build a model based on the sample.
       (default: 10)
   :param callbacks: A list of callbacks to handle. Handled sequentially
       at every callback point.
   :param verbose: Verbosity. (default: 1)
  
   Example:
       >>> import matchzoo as mz
       >>> train = mz.datasets.toy.load_data('train')
       >>> dev = mz.datasets.toy.load_data('dev')
       >>> prpr = mz.models.DenseBaseline.get_default_preprocessor()
       >>> train = prpr.fit_transform(train, verbose=0)
       >>> dev = prpr.transform(dev, verbose=0)
       >>> model = mz.models.DenseBaseline()
       >>> model.params['input_shapes'] = prpr.context['input_shapes']
       >>> model.params['task'] = mz.tasks.Ranking()
       >>> tuner = mz.auto.Tuner(
       ...     params=model.params,
       ...     train_data=train,
       ...     test_data=dev,
       ...     num_runs=1,
       ...     verbose=0
       ... )
       >>> results = tuner.tune()
       >>> sorted(results['best'].keys())
       ['#', 'params', 'sample', 'score']
  
   
class_docstr_tok: ["Model","hyper-parameters","tuner",".","`","model.params.hyper_space","`","reprensents","the","model","'s","hyper-parameters","search","space",",","which","is","the","cross-product","of","individual","hyper","parameter's","hyper","space",".","When","a","`","Tuner","`","builds","a","model",",","for","each","hyper","parameter","in","`","model.params","`",",","if","the","hyper-parameter","has","a","hyper-space",",","then","a","sample","will","be","taken","in","the","space",".","However",",","if","the","hyper-parameter","does","not","have","a","hyper-space",",","then","the","default","value","of","the","hyper-parameter","will","be","used",".","See","`","tutorials\/model_tuning.ipynb","`","for","a","detailed","walkthrough","on","usage",".",":","param","params",":","A","completed","parameter","table","to","tune",".","Usually","`","model.params","`","of","the","desired","model","to","tune",".","`","params.completed","(",")","`","should","be","`","True","`",".",":","param","train_data",":","Training","data","to","use",".","Either","a","preprocessed","`","DataPack","`",",","or","a","`","DataGenerator","`",".",":","param","test_data",":","Testing","data","to","use",".","A","preprocessed","`","DataPack","`",".",":","param","fit_kwargs",":","Extra","keyword","arguments","to","pass","to","`","fit","`",".","(","default",":","`","dict","(","epochs=10",",","verbose=0",")","`",")",":","param","evaluate_kwargs",":","Extra","keyword","arguments","to","pass","to","`","evaluate","`",".",":","param","metric",":","Metric","to","tune","upon",".","Must","be","one","of","the","metrics","in","`","model.params","[","'task","'","]",".metrics","`",".","(","default",":","the","first","metric","in","`","params.","[","'task","'","]",".metrics","`",".",":","param","mode",":","Either","`","maximize","`","the","metric","or","`","minimize","`","the","metric",".","(","default",":","'maximize","'",")",":","param","num_runs",":","Number","of","runs",".","Each","run","takes","a","sample","in","`","params.hyper_space","`","and","build","a","model","based","on","the","sample",".","(","default",":","10",")",":","param","callbacks",":","A","list","of","callbacks","to","handle",".","Handled","sequentially","at","every","callback","point",".",":","param","verbose",":","Verbosity",".","(","default",":","1",")","Example",":",">",">",">","import","matchzoo","as","mz",">",">",">","train","=","mz.datasets.toy.load_data","(","'train","'",")",">",">",">","dev","=","mz.datasets.toy.load_data","(","'dev","'",")",">",">",">","prpr","=","mz.models.DenseBaseline.get_default_preprocessor","(",")",">",">",">","train","=","prpr.fit_transform","(","train",",","verbose=0",")",">",">",">","dev","=","prpr.transform","(","dev",",","verbose=0",")",">",">",">","model","=","mz.models.DenseBaseline","(",")",">",">",">","model.params","[","'input_shapes","'","]","=","prpr.context","[","'input_shapes","'","]",">",">",">","model.params","[","'task","'","]","=","mz.tasks.Ranking","(",")",">",">",">","tuner","=","mz.auto.Tuner","(","...","params=model.params",",","...","train_data=train",",","...","test_data=dev",",","...","num_runs=1",",","...","verbose=0","...",")",">",">",">","results","=","tuner.tune","(",")",">",">",">","sorted","(","results","[","'best","'","]",".keys","(",")",")","[","'","#","'",",","'params","'",",","'sample","'",",","'score","'","]"]
code: def _validate_metric(cls, params, metric):
      if metric not in params["task"].metrics:
          raise ValueError("Target metric does not exist in the task.")
  
imports: import copy
  import typing
  import logging
  import hyperopt
  import matchzoo
  from matchzoo.engine.base_metric import BaseMetric
  from .callbacks.callback import Callback
label_desc: Use image node_id 37 for calling the Tuner obj's underlying member method code with example usage: obj._validate_metric(cls, params, metric) without return types