class_docstr: Estimator to perform a grid search given a blackbox estimator algorithm.
  
  The approach used is taken from section 3.4 of
  :footcite:t:`agarwal2018reductions`.
  
  Read more in the :ref:`User Guide <grid_search>`.
  
  .. versionadded:: 0.3.0
  
  .. versionchanged:: 0.4.6
      Enabled for more than two sensitive feature values
  
  Parameters
  ----------
  estimator : estimator
      An estimator implementing methods :code:`fit(X, y, sample_weight)` and
      :code:`predict(X)`, where `X` is the matrix of features, `y` is the
      vector of labels (binary classification) or continuous values
      (regression), and `sample_weight` is a vector of weights.
      In binary classification labels `y` and predictions returned by
      :code:`predict(X)` are either 0 or 1.
      In regression values `y` and predictions are continuous.
  constraints : fairlearn.reductions.Moment
      The disparity constraints expressed as moments
  selection_rule : str
      Specifies the procedure for selecting the best model found by the grid
      search. At the present time, the only valid value is
      "tradeoff_optimization" which minimizes a weighted sum of the error
      rate and constraint violation.
  constraint_weight : float
      When the `selection_rule` is "tradeoff_optimization" this specifies
      the relative weight put on the constraint violation when selecting the
      best model. The weight placed on the error rate will be
      :code:`1-constraint_weight`
  grid_size : int
      The number of Lagrange multipliers to generate in the grid
  grid_limit : float
      The largest Lagrange multiplier to generate. The grid will contain
      values distributed between :code:`-grid_limit` and :code:`grid_limit`
      by default
  grid_offset : :class:`pandas:pandas.DataFrame`
      Shifts the grid of Lagrangian multiplier by that value.
      It is '0' by default
  grid :
      Instead of supplying a size and limit for the grid, users may specify
      the exact set of Lagrange multipliers they desire using this argument.
  sample_weight_name : str
      Name of the argument to `estimator.fit()` which supplies the sample weights
      (defaults to `sample_weight`)
  
      .. versionadded:: 0.5.0
class_docstr_tok: ["Estimator","to","perform","a","grid","search","given","a","blackbox","estimator","algorithm",".","The","approach","used","is","taken","from","section","3.4","of",":","footcite",":","t",":","`","agarwal2018reductions","`",".","Read","more","in","the",":","ref",":","`","User","Guide","<","grid_search",">","`",".","..","versionadded",":",":","0.3.0","..","versionchanged",":",":","0.4.6","Enabled","for","more","than","two","sensitive","feature","values","Parameters","--","--","--","--","--","estimator",":","estimator","An","estimator","implementing","methods",":","code",":","`","fit","(","X",",","y",",","sample_weight",")","`","and",":","code",":","`","predict","(","X",")","`",",","where","`","X","`","is","the","matrix","of","features",",","`","y","`","is","the","vector","of","labels","(","binary","classification",")","or","continuous","values","(","regression",")",",","and","`","sample_weight","`","is","a","vector","of","weights",".","In","binary","classification","labels","`","y","`","and","predictions","returned","by",":","code",":","`","predict","(","X",")","`","are","either","0","or","1",".","In","regression","values","`","y","`","and","predictions","are","continuous",".","constraints",":","fairlearn.reductions.Moment","The","disparity","constraints","expressed","as","moments","selection_rule",":","str","Specifies","the","procedure","for","selecting","the","best","model","found","by","the","grid","search",".","At","the","present","time",",","the","only","valid","value","is","``","tradeoff_optimization","''","which","minimizes","a","weighted","sum","of","the","error","rate","and","constraint","violation",".","constraint_weight",":","float","When","the","`","selection_rule","`","is","``","tradeoff_optimization","''","this","specifies","the","relative","weight","put","on","the","constraint","violation","when","selecting","the","best","model",".","The","weight","placed","on","the","error","rate","will","be",":","code",":","`","1-constraint_weight","`","grid_size",":","int","The","number","of","Lagrange","multipliers","to","generate","in","the","grid","grid_limit",":","float","The","largest","Lagrange","multiplier","to","generate",".","The","grid","will","contain","values","distributed","between",":","code",":","`","-grid_limit","`","and",":","code",":","`","grid_limit","`","by","default","grid_offset",":",":","class",":","`","pandas",":","pandas.DataFrame","`","Shifts","the","grid","of","Lagrangian","multiplier","by","that","value",".","It","is","'","0","'","by","default","grid",":","Instead","of","supplying","a","size","and","limit","for","the","grid",",","users","may","specify","the","exact","set","of","Lagrange","multipliers","they","desire","using","this","argument",".","sample_weight_name",":","str","Name","of","the","argument","to","`","estimator.fit","(",")","`","which","supplies","the","sample","weights","(","defaults","to","`","sample_weight","`",")","..","versionadded",":",":","0.5.0"]
docstr: Provide a prediction using the best model found by the grid search.
  
  This dispatches `X` to the :code:`predict(X)` method of the
  selected estimator, and hence the return type is dependent on that method.
  
  :param X: Feature data
  :type X: numpy.ndarray or pandas.DataFrame
docstr_tok: ["Provide","a","prediction","using","the","best","model","found","by","the","grid","search",".","This","dispatches","`","X","`","to","the",":","code",":","`","predict","(","X",")","`","method","of","the","selected","estimator",",","and","hence","the","return","type","is","dependent","on","that","method",".",":","param","X",":","Feature","data",":","type","X",":","numpy.ndarray","or","pandas.DataFrame"]
code: def predict(self, X):
      """Provide a prediction using the best model found by the grid search.
  
      This dispatches `X` to the :code:`predict(X)` method of the
      selected estimator, and hence the return type is dependent on that method.
  
      :param X: Feature data
      :type X: numpy.ndarray or pandas.DataFrame
      """
      check_is_fitted(self)
      return self.predictors_[self.best_idx_].predict(X)
  
file_path: fairlearn/fairlearn/reductions/_grid_search/grid_search.py
imports: import copy
  import logging
  from time import time
  import numpy
  import pandas
  from sklearn.base import BaseEstimator, MetaEstimatorMixin
  from sklearn.dummy import DummyClassifier
  from sklearn.utils.validation import check_is_fitted
  from fairlearn.reductions._moments import ClassificationMoment, Moment
  from ._grid_generator import _GridGenerator
label_desc: Use image node_id 3 for calling the GridSearch obj's underlying member method code with example usage: obj.predict(X) and returns: self