class_docstr: The :class:`GridSearchCV` class computes accuracy metrics for an
  algorithm on various combinations of parameters, over a cross-validation
  procedure. This is useful for finding the best set of parameters for a
  prediction algorithm. It is analogous to `GridSearchCV
  <https://scikit-learn.org/stable/modules/generated/sklearn.
  model_selection.GridSearchCV.html>`_ from scikit-learn.
  
  See an example in the :ref:`User Guide <tuning_algorithm_parameters>`.
  
  Args:
      algo_class(:obj:`AlgoBase             <surprise.prediction_algorithms.algo_base.AlgoBase>`): The class
          of the algorithm to evaluate.
      param_grid(dict): Dictionary with algorithm parameters as keys and
          list of values as keys. All combinations will be evaluated with
          desired algorithm. Dict parameters such as ``sim_options`` require
          special treatment, see :ref:`this note<grid_search_note>`.
      measures(list of string): The performance measures to compute. Allowed
          names are function names as defined in the :mod:`accuracy
          <surprise.accuracy>` module.  Default is ``['rmse', 'mae']``.
      cv(cross-validation iterator, int or ``None``): Determines how the
          ``data`` parameter will be split (i.e. how trainsets and testsets
          will be defined). If an int is passed, :class:`KFold
          <surprise.model_selection.split.KFold>` is used with the
          appropriate ``n_splits`` parameter. If ``None``, :class:`KFold
          <surprise.model_selection.split.KFold>` is used with
          ``n_splits=5``.
      refit(bool or str): If ``True``, refit the algorithm on the whole
          dataset using the set of parameters that gave the best average
          performance for the first measure of ``measures``. Other measures
          can be used by passing a string (corresponding to the measure
          name). Then, you can use the ``test()`` and ``predict()`` methods.
          ``refit`` can only be used if the ``data`` parameter given to
          ``fit()`` hasn't been loaded with :meth:`load_from_folds()
          <surprise.dataset.Dataset.load_from_folds>`. Default is ``False``.
      return_train_measures(bool): Whether to compute performance measures on
          the trainsets. If ``True``, the ``cv_results`` attribute will
          also contain measures for trainsets. Default is ``False``.
      n_jobs(int): The maximum number of parallel training procedures.
  
          - If ``-1``, all CPUs are used.
          - If ``1`` is given, no parallel computing code is used at all,                which is useful for debugging.
          - For ``n_jobs`` below ``-1``, ``(n_cpus + n_jobs + 1)`` are                used.  For example, with ``n_jobs = -2`` all CPUs but one are                used.
  
          Default is ``1``.
      pre_dispatch(int or string): Controls the number of jobs that get
          dispatched during parallel execution. Reducing this number can be
          useful to avoid an explosion of memory consumption when more jobs
          get dispatched than CPUs can process. This parameter can be:
  
          - ``None``, in which case all the jobs are immediately created                and spawned. Use this for lightweight and fast-running                jobs, to avoid delays due to on-demand spawning of the                jobs.
          - An int, giving the exact number of total jobs that are                spawned.
          - A string, giving an expression as a function of ``n_jobs``,                as in ``'2*n_jobs'``.
  
          Default is ``'2*n_jobs'``.
      joblib_verbose(int): Controls the verbosity of joblib: the higher, the
          more messages.
  
  Attributes:
      best_estimator (dict of AlgoBase):
          Using an accuracy measure as key, get the algorithm that gave the
          best accuracy results for the chosen measure, averaged over all
          splits.
      best_score (dict of floats):
          Using an accuracy measure as key, get the best average score
          achieved for that measure.
      best_params (dict of dicts):
          Using an accuracy measure as key, get the parameters combination
          that gave the best accuracy results for the chosen measure (on
          average).
      best_index  (dict of ints):
          Using an accuracy measure as key, get the index that can be used
          with ``cv_results`` that achieved the highest accuracy for that
          measure (on average).
      cv_results (dict of arrays):
          A dict that contains accuracy measures over all splits, as well as
          train and test time for each parameter combination. Can be imported
          into a pandas `DataFrame` (see :ref:`example
          <cv_results_example>`).
code: def __init__(
      self,
      algo_class,
      param_grid,
      measures=["rmse", "mae"],
      cv=None,
      refit=False,
      return_train_measures=False,
      n_jobs=1,
      pre_dispatch="2*n_jobs",
      joblib_verbose=0,
  ):
      super().__init__(
          algo_class=algo_class,
          measures=measures,
          cv=cv,
          refit=refit,
          return_train_measures=return_train_measures,
          n_jobs=n_jobs,
          pre_dispatch=pre_dispatch,
          joblib_verbose=joblib_verbose,
      )
  
      self.param_grid = self._parse_options(param_grid.copy())
      self.param_combinations = [
          dict(zip(self.param_grid, v))
          for v in product(*self.param_grid.values())
      ]
  
imports: from abc import ABC, abstractmethod
  from itertools import product
  import numpy
  from joblib import delayed, Parallel
  from ..dataset import DatasetUserFolds
  from ..utils import get_rng
  from .split import get_cv
  from .validation import fit_and_score
label_desc: Use image node_id 1 to create a new GridSearchCV object from inherited base classes: BaseSearchCV with example: obj = GridSearchCV(algo_class, param_grid, measures, cv, refit, return_train_measures, n_jobs, pre_dispatch, joblib_verbose)