class_docstr: Construct an estimator per data group. Splits data by values of a single column and fits one estimator per such
  column.
  
  Parameters
  ----------
  estimator : scikit-learn compatible estimator/pipeline
      The estimator/pipeline to be applied per group.
  groups : int | str | List[int] | List[str]
      The column(s) of the array/dataframe to select as a grouping parameter set.
  shrinkage : Literal["constant", "min_n_obs", "relative"] | Callable | None, default=None
      How to perform shrinkage:
  
      - `None`: No shrinkage (default)
      - `"constant"`: shrunk prediction for a level is weighted average of its prediction and its parents prediction
      - `"min_n_obs"`: shrunk prediction is the prediction for the smallest group with at least n observations in it
      - `"relative"`: each group-level is weight according to its size
      - `Callable`: a function that takes a list of group lengths and returns an array of the same size with the
          weights for each group
  use_global_model : bool, default=True
  
      - With shrinkage: whether to have a model over the entire input as first group
      - Without shrinkage: whether or not to fall back to a general model in case the group parameter is not found
          during `.predict()`
  check_X : bool, default=True
      Whether to validate `X` to be non-empty 2D array of finite values and attempt to cast `X` to float.
      If disabled, the model/pipeline is expected to handle e.g. missing, non-numeric, or non-finite values.
  **shrinkage_kwargs : dict
      Keyword arguments to the shrinkage function
class_docstr_tok: ["Construct","an","estimator","per","data","group",".","Splits","data","by","values","of","a","single","column","and","fits","one","estimator","per","such","column",".","Parameters","--","--","--","--","--","estimator",":","scikit-learn","compatible","estimator\/pipeline","The","estimator\/pipeline","to","be","applied","per","group",".","groups",":","int","|","str","|","List","[","int","]","|","List","[","str","]","The","column","(","s",")","of","the","array\/dataframe","to","select","as","a","grouping","parameter","set",".","shrinkage",":","Literal","[","``","constant","''",",","``","min_n_obs","''",",","``","relative","''","]","|","Callable","|","None",",","default=None","How","to","perform","shrinkage",":","-","`","None","`",":","No","shrinkage","(","default",")","-","`","``","constant","''","`",":","shrunk","prediction","for","a","level","is","weighted","average","of","its","prediction","and","its","parents","prediction","-","`","``","min_n_obs","''","`",":","shrunk","prediction","is","the","prediction","for","the","smallest","group","with","at","least","n","observations","in","it","-","`","``","relative","''","`",":","each","group-level","is","weight","according","to","its","size","-","`","Callable","`",":","a","function","that","takes","a","list","of","group","lengths","and","returns","an","array","of","the","same","size","with","the","weights","for","each","group","use_global_model",":","bool",",","default=True","-","With","shrinkage",":","whether","to","have","a","model","over","the","entire","input","as","first","group","-","Without","shrinkage",":","whether","or","not","to","fall","back","to","a","general","model","in","case","the","group","parameter","is","not","found","during","`",".predict","(",")","`","check_X",":","bool",",","default=True","Whether","to","validate","`","X","`","to","be","non-empty","2D","array","of","finite","values","and","attempt","to","cast","`","X","`","to","float",".","If","disabled",",","the","model\/pipeline","is","expected","to","handle","e.g",".","missing",",","non-numeric",",","or","non-finite","values",".","*","*","shrinkage_kwargs",":","dict","Keyword","arguments","to","the","shrinkage","function"]
docstr: Fit one estimator for each group of training data `X` and `y`.
  
  Will also learn the groups that exist within the dataset.
  
  If `use_global_model=True` a fallback estimator will be fitted on the entire dataset in case a group is not
  found during `.predict()`.
  
  Parameters
  ----------
  X : array-like of shape (n_samples, n_features)
      Training data.
  y : array-like of shape (n_samples,), default=None
      Target values.
  
  Returns
  -------
  self : GroupedPredictor
      The fitted estimator.
docstr_tok: ["Fit","one","estimator","for","each","group","of","training","data","`","X","`","and","`","y","`",".","Will","also","learn","the","groups","that","exist","within","the","dataset",".","If","`","use_global_model=True","`","a","fallback","estimator","will","be","fitted","on","the","entire","dataset","in","case","a","group","is","not","found","during","`",".predict","(",")","`",".","Parameters","--","--","--","--","--","X",":","array-like","of","shape","(","n_samples",",","n_features",")","Training","data",".","y",":","array-like","of","shape","(","n_samples",",",")",",","default=None","Target","values",".","Returns","--","--","--","-","self",":","GroupedPredictor","The","fitted","estimator","."]
code: def fit(self, X, y=None):
      """Fit one estimator for each group of training data `X` and `y`.
  
      Will also learn the groups that exist within the dataset.
  
      If `use_global_model=True` a fallback estimator will be fitted on the entire dataset in case a group is not
      found during `.predict()`.
  
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features)
          Training data.
      y : array-like of shape (n_samples,), default=None
          Target values.
  
      Returns
      -------
      self : GroupedPredictor
          The fitted estimator.
      """
      X_group, X_value = _split_groups_and_values(
          X,
          self.groups,
          min_value_cols=0,
          check_X=self.check_X,
          **self._check_kwargs,
      )
  
      X_group = self.__add_shrinkage_column(X_group)
  
      if y is not None:
          y = check_array(y, ensure_2d=False)
  
      if self.shrinkage is not None:
          self.__set_shrinkage_function()
  
      # List of all hierarchical subsets of columns
      self.group_colnames_hierarchical_ = expanding_list(
          X_group.columns, list
      )
  
      self.fallback_ = None
  
      if self.shrinkage is None and self.use_global_model:
          self.fallback_ = clone(self.estimator).fit(X_value, y)
  
      if self.shrinkage is not None:
          self.estimators_ = self.__fit_shrinkage_groups(
              X_group, X_value, y
          )
      else:
          self.estimators_ = self.__fit_grouped_estimator(
              X_group, X_value, y
          )
  
      self.groups_ = as_list(self.estimators_.keys())
  
      if self.shrinkage is not None:
          self.shrinkage_factors_ = self.__get_shrinkage_factor(X_group)
  
      return self
  
imports: import numpy
  import pandas
  from sklearn import clone
  from sklearn.base import BaseEstimator, is_classifier
  from sklearn.utils.metaestimators import available_if
  from sklearn.utils.validation import check_array, check_is_fitted
  from sklego.common import as_list, expanding_list
  from sklego.meta._grouped_utils import _split_groups_and_values, constant_shrinkage, min_n_obs_shrinkage, relative_shrinkage
label_desc: Use image node_id 9 for calling the GroupedPredictor obj's underlying member method code with example usage: obj.fit(X, y) and returns: self