class_docstr: Generalized linear mixed model.
  
  Supported targets: binomial and continuous. For polynomial target support, see PolynomialWrapper.
  
  This is a supervised encoder similar to TargetEncoder or MEstimateEncoder, but there are some advantages:
  
      1. Solid statistical theory behind the technique. Mixed effects models are a mature branch of statistics.
      2. No hyper-parameters to tune. The amount of shrinkage is automatically determined through the estimation
      process. In short, the less observations a category has and/or the more the outcome varies for a category
      then the higher the regularization towards "the prior" or "grand mean".
      3. The technique is applicable for both continuous and binomial targets. If the target is continuous,
      the encoder returns regularized difference of the observation's category from the global mean.
  
  If the target is binomial, the encoder returns regularized log odds per category.
  
  In comparison to JamesSteinEstimator, this encoder utilizes generalized linear mixed models from statsmodels library.
  
  Note: This is an alpha implementation. The API of the method may change in the future.
  
  Parameters
  ----------
  
  verbose: int
      integer indicating verbosity of the output. 0 for none.
  cols: list
      a list of columns to encode, if None, all string columns will be encoded.
  drop_invariant: bool
      boolean for whether or not to drop encoded columns with 0 variance.
  return_df: bool
      boolean for whether to return a pandas DataFrame from transform (otherwise it will be a numpy array).
  handle_missing: str
      options are 'return_nan', 'error' and 'value', defaults to 'value', which returns 0.
  handle_unknown: str
      options are 'return_nan', 'error' and 'value', defaults to 'value', which returns 0.
  randomized: bool,
      adds normal (Gaussian) distribution noise into training data in order to decrease overfitting (testing data are untouched).
  sigma: float
      standard deviation (spread or "width") of the normal distribution.
  binomial_target: bool
      if True, the target must be binomial with values {0, 1} and Binomial mixed model is used.
      If False, the target must be continuous and Linear mixed model is used.
      If None (the default), a heuristic is applied to estimate the target type.
  
  Example
  -------
  >>> from category_encoders import *
  >>> import pandas as pd
  >>> from sklearn.datasets import fetch_openml
  >>> bunch = fetch_openml(name="house_prices", as_frame=True)
  >>> display_cols = ["Id", "MSSubClass", "MSZoning", "LotFrontage", "YearBuilt", "Heating", "CentralAir"]
  >>> y = bunch.target > 200000
  >>> X = pd.DataFrame(bunch.data, columns=bunch.feature_names)[display_cols]
  >>> enc = GLMMEncoder(cols=['CentralAir', 'Heating']).fit(X, y)
  >>> numeric_dataset = enc.transform(X)
  >>> print(numeric_dataset.info())
  <class 'pandas.core.frame.DataFrame'>
  RangeIndex: 1460 entries, 0 to 1459
  Data columns (total 7 columns):
   #   Column       Non-Null Count  Dtype  
  ---  ------       --------------  -----  
   0   Id           1460 non-null   float64
   1   MSSubClass   1460 non-null   float64
   2   MSZoning     1460 non-null   object 
   3   LotFrontage  1201 non-null   float64
   4   YearBuilt    1460 non-null   float64
   5   Heating      1460 non-null   float64
   6   CentralAir   1460 non-null   float64
  dtypes: float64(6), object(1)
  memory usage: 80.0+ KB
  None
  
  References
  ----------
  
  .. [1] Data Analysis Using Regression and Multilevel/Hierarchical Models, page 253, from
  https://faculty.psau.edu.sa/filedownload/doc-12-pdf-a1997d0d31f84d13c1cdc44ac39a8f2c-original.pdf
class_docstr_tok: ["Generalized","linear","mixed","model",".","Supported","targets",":","binomial","and","continuous",".","For","polynomial","target","support",",","see","PolynomialWrapper",".","This","is","a","supervised","encoder","similar","to","TargetEncoder","or","MEstimateEncoder",",","but","there","are","some","advantages",":","1",".","Solid","statistical","theory","behind","the","technique",".","Mixed","effects","models","are","a","mature","branch","of","statistics",".","2",".","No","hyper-parameters","to","tune",".","The","amount","of","shrinkage","is","automatically","determined","through","the","estimation","process",".","In","short",",","the","less","observations","a","category","has","and\/or","the","more","the","outcome","varies","for","a","category","then","the","higher","the","regularization","towards","``","the","prior","''","or","``","grand","mean","''",".","3",".","The","technique","is","applicable","for","both","continuous","and","binomial","targets",".","If","the","target","is","continuous",",","the","encoder","returns","regularized","difference","of","the","observation","'s","category","from","the","global","mean",".","If","the","target","is","binomial",",","the","encoder","returns","regularized","log","odds","per","category",".","In","comparison","to","JamesSteinEstimator",",","this","encoder","utilizes","generalized","linear","mixed","models","from","statsmodels","library",".","Note",":","This","is","an","alpha","implementation",".","The","API","of","the","method","may","change","in","the","future",".","Parameters","--","--","--","--","--","verbose",":","int","integer","indicating","verbosity","of","the","output",".","0","for","none",".","cols",":","list","a","list","of","columns","to","encode",",","if","None",",","all","string","columns","will","be","encoded",".","drop_invariant",":","bool","boolean","for","whether","or","not","to","drop","encoded","columns","with","0","variance",".","return_df",":","bool","boolean","for","whether","to","return","a","pandas","DataFrame","from","transform","(","otherwise","it","will","be","a","numpy","array",")",".","handle_missing",":","str","options","are","'return_nan","'",",","'error","'","and","'value","'",",","defaults","to","'value","'",",","which","returns","0.","handle_unknown",":","str","options","are","'return_nan","'",",","'error","'","and","'value","'",",","defaults","to","'value","'",",","which","returns","0.","randomized",":","bool",",","adds","normal","(","Gaussian",")","distribution","noise","into","training","data","in","order","to","decrease","overfitting","(","testing","data","are","untouched",")",".","sigma",":","float","standard","deviation","(","spread","or","``","width","''",")","of","the","normal","distribution",".","binomial_target",":","bool","if","True",",","the","target","must","be","binomial","with","values","{","0",",","1","}","and","Binomial","mixed","model","is","used",".","If","False",",","the","target","must","be","continuous","and","Linear","mixed","model","is","used",".","If","None","(","the","default",")",",","a","heuristic","is","applied","to","estimate","the","target","type",".","Example","--","--","--","-",">",">",">","from","category_encoders","import","*",">",">",">","import","pandas","as","pd",">",">",">","from","sklearn.datasets","import","fetch_openml",">",">",">","bunch","=","fetch_openml","(","name=","''","house_prices","''",",","as_frame=True",")",">",">",">","display_cols","=","[","``","Id","''",",","``","MSSubClass","''",",","``","MSZoning","''",",","``","LotFrontage","''",",","``","YearBuilt","''",",","``","Heating","''",",","``","CentralAir","''","]",">",">",">","y","=","bunch.target",">","200000",">",">",">","X","=","pd.DataFrame","(","bunch.data",",","columns=bunch.feature_names",")","[","display_cols","]",">",">",">","enc","=","GLMMEncoder","(","cols=","[","'CentralAir","'",",","'Heating","'","]",")",".fit","(","X",",","y",")",">",">",">","numeric_dataset","=","enc.transform","(","X",")",">",">",">","print","(","numeric_dataset.info","(",")",")","<","class","'pandas.core.frame.DataFrame","'",">","RangeIndex",":","1460","entries",",","0","to","1459","Data","columns","(","total","7","columns",")",":","#","Column","Non-Null","Count","Dtype","--","-","--","--","--","--","--","--","--","--","--","--","--","--","-","0","Id","1460","non-null","float64","1","MSSubClass","1460","non-null","float64","2","MSZoning","1460","non-null","object","3","LotFrontage","1201","non-null","float64","4","YearBuilt","1460","non-null","float64","5","Heating","1460","non-null","float64","6","CentralAir","1460","non-null","float64","dtypes",":","float64","(","6",")",",","object","(","1",")","memory","usage",":","80.0+","KB","None","References","--","--","--","--","--","..","[","1","]","Data","Analysis","Using","Regression","and","Multilevel\/Hierarchical","Models",",","page","253",",","from","https",":","\/\/faculty.psau.edu.sa\/filedownload\/doc-12-pdf-a1997d0d31f84d13c1cdc44ac39a8f2c-original.pdf"]
code: def _fit(self, X, y, **kwargs):
      y = y.astype(float)
  
      self.ordinal_encoder = OrdinalEncoder(
          verbose=self.verbose,
          cols=self.cols,
          handle_unknown="value",
          handle_missing="value",
      )
      self.ordinal_encoder = self.ordinal_encoder.fit(X)
      X_ordinal = self.ordinal_encoder.transform(X)
  
      # Training
      self.mapping = self._train(X_ordinal, y)
  
file_path: category_encoders/category_encoders/glmm.py
imports: import warnings
  import re
  import numpy
  import pandas
  from sklearn.utils.random import check_random_state
  from category_encoders.ordinal import OrdinalEncoder
  import category_encoders.utils
  import statsmodels.formula.api
  from statsmodels.genmod.bayes_mixed_glm import BinomialBayesMixedGLM
label_desc: Use image node_id 2 for calling the GLMMEncoder obj's underlying member method code with example usage: obj._fit(X, y) without return types