class_docstr: Abstract base class of all MatchZoo models.
  
  MatchZoo models are wrapped over keras models, and the actual keras model
  built can be accessed by `model.backend`. `params` is a set of model
  hyper-parameters that deterministically builds a model. In other words,
  `params['model_class'](params=params)` of the same `params` always create
  models with the same structure.
  
  :param params: Model hyper-parameters. (default: return value from
      :meth:`get_default_params`)
  :param backend: A keras model as the model backend. Usually not passed as
      an argument.
  
  Example:
      >>> BaseModel()  # doctest: +ELLIPSIS
      Traceback (most recent call last):
      ...
      TypeError: Can't instantiate abstract class BaseModel ...
      >>> class MyModel(BaseModel):
      ...     def build(self):
      ...         pass
      >>> isinstance(MyModel(), BaseModel)
      True
class_docstr_tok: ["Abstract","base","class","of","all","MatchZoo","models",".","MatchZoo","models","are","wrapped","over","keras","models",",","and","the","actual","keras","model","built","can","be","accessed","by","`","model.backend","`",".","`","params","`","is","a","set","of","model","hyper-parameters","that","deterministically","builds","a","model",".","In","other","words",",","`","params","[","'model_class","'","]","(","params=params",")","`","of","the","same","`","params","`","always","create","models","with","the","same","structure",".",":","param","params",":","Model","hyper-parameters",".","(","default",":","return","value","from",":","meth",":","`","get_default_params","`",")",":","param","backend",":","A","keras","model","as","the","model","backend",".","Usually","not","passed","as","an","argument",".","Example",":",">",">",">","BaseModel","(",")","#","doctest",":","+ELLIPSIS","Traceback","(","most","recent","call","last",")",":","...","TypeError",":","Ca","n't","instantiate","abstract","class","BaseModel","...",">",">",">","class","MyModel","(","BaseModel",")",":","...","def","build","(","self",")",":","...","pass",">",">",">","isinstance","(","MyModel","(",")",",","BaseModel",")","True"]
docstr: Evaluate the model.
  
  :param x: Input data.
  :param y: Labels.
  :param batch_size: Number of samples when `predict` for evaluation.
      (default: 128)
  
  Examples::
      >>> import matchzoo as mz
      >>> data_pack = mz.datasets.toy.load_data()
      >>> preprocessor = mz.preprocessors.NaivePreprocessor()
      >>> data_pack = preprocessor.fit_transform(data_pack, verbose=0)
      >>> m = mz.models.DenseBaseline()
      >>> m.params['task'] = mz.tasks.Ranking()
      >>> m.params['task'].metrics = [
      ...     'acc', 'mse', 'mae', 'ce',
      ...     'average_precision', 'precision', 'dcg', 'ndcg',
      ...     'mean_reciprocal_rank', 'mean_average_precision', 'mrr',
      ...     'map', 'MAP',
      ...     mz.metrics.AveragePrecision(threshold=1),
      ...     mz.metrics.Precision(k=2, threshold=2),
      ...     mz.metrics.DiscountedCumulativeGain(k=2),
      ...     mz.metrics.NormalizedDiscountedCumulativeGain(
      ...         k=3, threshold=-1),
      ...     mz.metrics.MeanReciprocalRank(threshold=2),
      ...     mz.metrics.MeanAveragePrecision(threshold=3)
      ... ]
      >>> m.guess_and_fill_missing_params(verbose=0)
      >>> m.build()
      >>> m.compile()
      >>> x, y = data_pack.unpack()
      >>> evals = m.evaluate(x, y)
      >>> type(evals)
      <class 'dict'>
code: def evaluate(
      self,
      x: typing.Dict[str, np.ndarray],
      y: np.ndarray,
      batch_size: int = 128,
  ) -> typing.Dict[BaseMetric, float]:
      """
      Evaluate the model.
  
      :param x: Input data.
      :param y: Labels.
      :param batch_size: Number of samples when `predict` for evaluation.
          (default: 128)
  
      Examples::
          >>> import matchzoo as mz
          >>> data_pack = mz.datasets.toy.load_data()
          >>> preprocessor = mz.preprocessors.NaivePreprocessor()
          >>> data_pack = preprocessor.fit_transform(data_pack, verbose=0)
          >>> m = mz.models.DenseBaseline()
          >>> m.params['task'] = mz.tasks.Ranking()
          >>> m.params['task'].metrics = [
          ...     'acc', 'mse', 'mae', 'ce',
          ...     'average_precision', 'precision', 'dcg', 'ndcg',
          ...     'mean_reciprocal_rank', 'mean_average_precision', 'mrr',
          ...     'map', 'MAP',
          ...     mz.metrics.AveragePrecision(threshold=1),
          ...     mz.metrics.Precision(k=2, threshold=2),
          ...     mz.metrics.DiscountedCumulativeGain(k=2),
          ...     mz.metrics.NormalizedDiscountedCumulativeGain(
          ...         k=3, threshold=-1),
          ...     mz.metrics.MeanReciprocalRank(threshold=2),
          ...     mz.metrics.MeanAveragePrecision(threshold=3)
          ... ]
          >>> m.guess_and_fill_missing_params(verbose=0)
          >>> m.build()
          >>> m.compile()
          >>> x, y = data_pack.unpack()
          >>> evals = m.evaluate(x, y)
          >>> type(evals)
          <class 'dict'>
  
      """
      result = dict()
      matchzoo_metrics, keras_metrics = self._separate_metrics()
      y_pred = self.predict(x, batch_size)
  
      for metric in keras_metrics:
          metric_func = keras.metrics.get(metric)
          result[metric] = K.eval(
              K.mean(metric_func(K.variable(y), K.variable(y_pred)))
          )
  
      if matchzoo_metrics:
          if not isinstance(self.params["task"], tasks.Ranking):
              raise ValueError(
                  "Matchzoo metrics only works on ranking."
              )
          for metric in matchzoo_metrics:
              result[metric] = self._eval_metric_on_data_frame(
                  metric, x["id_left"], y, y_pred
              )
  
      return result
  
imports: import abc
  import typing
  from pathlib import Path
  import dill
  import numpy
  import keras
  import keras.backend
  import pandas
  import matchzoo
  from matchzoo import DataGenerator
  from matchzoo.engine import hyper_spaces
  from matchzoo.engine.base_preprocessor import BasePreprocessor
  from matchzoo.engine.base_metric import BaseMetric
  from matchzoo.engine.param_table import ParamTable
  from matchzoo.engine.param import Param
  from matchzoo import tasks
label_desc: Use image node_id 11 for calling the BaseModel obj's underlying member method code with example usage: obj.evaluate(x, y, batch_size) and returns: result