class_docstr: M-probability estimate of likelihood.
  
  Supported targets: binomial and continuous. For polynomial target support, see PolynomialWrapper.
  
  This is a simplified version of target encoder, which goes under names like m-probability estimate or
  additive smoothing with known incidence rates. In comparison to target encoder, m-probability estimate
  has only one tunable parameter (`m`), while target encoder has two tunable parameters (`min_samples_leaf`
  and `smoothing`).
  
  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 the prior probability.
  handle_unknown: str
      options are 'return_nan', 'error' and 'value', defaults to 'value', which returns the prior probability.
  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.
  m: float
      this is the "m" in the m-probability estimate. Higher value of m results into stronger shrinking.
      M is non-negative.
  
  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 = MEstimateEncoder(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] A Preprocessing Scheme for High-Cardinality Categorical Attributes in Classification and Prediction Problems, equation 7, from
  https://dl.acm.org/citation.cfm?id=507538
  
  .. [2] On estimating probabilities in tree pruning, equation 1, from
  https://link.springer.com/chapter/10.1007/BFb0017010
  
  .. [3] Additive smoothing, from
  https://en.wikipedia.org/wiki/Additive_smoothing#Generalized_to_the_case_of_known_incidence_rates
class_docstr_tok: ["M-probability","estimate","of","likelihood",".","Supported","targets",":","binomial","and","continuous",".","For","polynomial","target","support",",","see","PolynomialWrapper",".","This","is","a","simplified","version","of","target","encoder",",","which","goes","under","names","like","m-probability","estimate","or","additive","smoothing","with","known","incidence","rates",".","In","comparison","to","target","encoder",",","m-probability","estimate","has","only","one","tunable","parameter","(","`","m","`",")",",","while","target","encoder","has","two","tunable","parameters","(","`","min_samples_leaf","`","and","`","smoothing","`",")",".","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","the","prior","probability",".","handle_unknown",":","str","options","are","'return_nan","'",",","'error","'","and","'value","'",",","defaults","to","'value","'",",","which","returns","the","prior","probability",".","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",".","m",":","float","this","is","the","``","m","''","in","the","m-probability","estimate",".","Higher","value","of","m","results","into","stronger","shrinking",".","M","is","non-negative",".","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","=","MEstimateEncoder","(","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","]","A","Preprocessing","Scheme","for","High-Cardinality","Categorical","Attributes","in","Classification","and","Prediction","Problems",",","equation","7",",","from","https",":","\/\/dl.acm.org\/citation.cfm","?","id=507538","..","[","2","]","On","estimating","probabilities","in","tree","pruning",",","equation","1",",","from","https",":","\/\/link.springer.com\/chapter\/10.1007\/BFb0017010","..","[","3","]","Additive","smoothing",",","from","https",":","\/\/en.wikipedia.org\/wiki\/Additive_smoothing","#","Generalized_to_the_case_of_known_incidence_rates"]
code: def _transform(self, X, y=None):
      X = self.ordinal_encoder.transform(X)
  
      if self.handle_unknown == "error":
          if X[self.cols].isin([-1]).any().any():
              raise ValueError(
                  "Unexpected categories found in dataframe"
              )
  
      # Loop over the columns and replace the nominal values with the numbers
      X = self._score(X, y)
      return X
  
file_path: category_encoders/category_encoders/m_estimate.py
imports: import numpy
  from category_encoders.ordinal import OrdinalEncoder
  import category_encoders.utils
  from sklearn.utils.random import check_random_state
label_desc: Use image node_id 3 for calling the MEstimateEncoder obj's underlying member method code with example usage: obj._transform(X, y) and returns: X