class_docstr: The RareLabelEncoder() groups rare or infrequent categories in
  a new category called "Rare", or any other name entered by the user.
  
  For example in the variable colour, if the percentage of observations
  for the categories magenta, cyan and burgundy are < 5 %, all those
  categories will be replaced by the new label "Rare".
  
  **Note**
  
  Infrequent labels can also be grouped under a user defined name, for
  example 'Other'. The name to replace infrequent categories is defined
  with the parameter `replace_with`.
  
  The encoder will encode only categorical variables by default (type 'object' or
  'categorical'). You can pass a list of variables to encode.Alternatively, the
  encoder will find and encode all categorical variables (type 'object' or
  'categorical').
  
  With `ignore_format=True` you have the option to encode numerical variables as well.
  The procedure is identical, you can either enter the list of variables to encode, or
  the transformer will automatically select all variables.
  
  The encoder first finds the frequent labels for each variable (fit). The encoder
  then groups the infrequent labels under the new label 'Rare' or by another user
  defined string (transform).
  
  More details in the :ref:`User Guide <rarelabel_encoder>`.
  
  
  Parameters
  ----------
  tol: float, default=0.05
      The minimum frequency a label should have to be considered frequent.
      Categories with frequencies lower than tol will be grouped.
  
  n_categories: int, default=10
      The minimum number of categories a variable should have for the encoder
      to find frequent labels. If the variable contains less categories, all
      of them will be considered frequent.
  
  max_n_categories: int, default=None
      The maximum number of categories that should be considered frequent.
      If None, all categories with frequency above the tolerance (tol) will be
      considered frequent. If you enter 5, only the 5 most frequent categories will
      be retained and the rest grouped.
  
  replace_with: string, intege or float, default='Rare'
      The value that will be used to replace infrequent categories.
  
  {variables}
  
  {ignore_format}
  
  Attributes
  ----------
  encoder_dict_:
      Dictionary with the frequent categories, i.e., those that will be kept, per
      variable.
  
  {variables_}
  
  {feature_names_in_}
  
  {n_features_in_}
  
  Methods
  -------
  fit:
      Find frequent categories.
  
  {fit_transform}
  
  transform:
      Group rare categories
  
  Examples
  --------
  
  >>> import pandas as pd
  >>> from feature_engine.encoding import RareLabelEncoder
  >>> X = pd.DataFrame(dict(x1 = [1,2,3,4,5,6], x2 = ["b", "b", "b", "b", "b", "a"]))
  >>> rle = RareLabelEncoder(n_categories = 1, tol=0.2)
  >>> rle.fit(X)
  >>> rle.transform(X)
     x1    x2
  0   1     b
  1   2     b
  2   3     b
  3   4     b
  4   5     b
  5   6  Rare
class_docstr_tok: ["The","RareLabelEncoder","(",")","groups","rare","or","infrequent","categories","in","a","new","category","called","``","Rare","''",",","or","any","other","name","entered","by","the","user",".","For","example","in","the","variable","colour",",","if","the","percentage","of","observations","for","the","categories","magenta",",","cyan","and","burgundy","are","<","5","%",",","all","those","categories","will","be","replaced","by","the","new","label","``","Rare","''",".","*","*","Note","*","*","Infrequent","labels","can","also","be","grouped","under","a","user","defined","name",",","for","example","'Other","'",".","The","name","to","replace","infrequent","categories","is","defined","with","the","parameter","`","replace_with","`",".","The","encoder","will","encode","only","categorical","variables","by","default","(","type","'object","'","or","'categorical","'",")",".","You","can","pass","a","list","of","variables","to","encode.Alternatively",",","the","encoder","will","find","and","encode","all","categorical","variables","(","type","'object","'","or","'categorical","'",")",".","With","`","ignore_format=True","`","you","have","the","option","to","encode","numerical","variables","as","well",".","The","procedure","is","identical",",","you","can","either","enter","the","list","of","variables","to","encode",",","or","the","transformer","will","automatically","select","all","variables",".","The","encoder","first","finds","the","frequent","labels","for","each","variable","(","fit",")",".","The","encoder","then","groups","the","infrequent","labels","under","the","new","label","'Rare","'","or","by","another","user","defined","string","(","transform",")",".","More","details","in","the",":","ref",":","`","User","Guide","<","rarelabel_encoder",">","`",".","Parameters","--","--","--","--","--","tol",":","float",",","default=0.05","The","minimum","frequency","a","label","should","have","to","be","considered","frequent",".","Categories","with","frequencies","lower","than","tol","will","be","grouped",".","n_categories",":","int",",","default=10","The","minimum","number","of","categories","a","variable","should","have","for","the","encoder","to","find","frequent","labels",".","If","the","variable","contains","less","categories",",","all","of","them","will","be","considered","frequent",".","max_n_categories",":","int",",","default=None","The","maximum","number","of","categories","that","should","be","considered","frequent",".","If","None",",","all","categories","with","frequency","above","the","tolerance","(","tol",")","will","be","considered","frequent",".","If","you","enter","5",",","only","the","5","most","frequent","categories","will","be","retained","and","the","rest","grouped",".","replace_with",":","string",",","intege","or","float",",","default='Rare'","The","value","that","will","be","used","to","replace","infrequent","categories",".","{","variables","}","{","ignore_format","}","Attributes","--","--","--","--","--","encoder_dict_",":","Dictionary","with","the","frequent","categories",",","i.e.",",","those","that","will","be","kept",",","per","variable",".","{","variables_","}","{","feature_names_in_","}","{","n_features_in_","}","Methods","--","--","--","-","fit",":","Find","frequent","categories",".","{","fit_transform","}","transform",":","Group","rare","categories","Examples","--","--","--","--",">",">",">","import","pandas","as","pd",">",">",">","from","feature_engine.encoding","import","RareLabelEncoder",">",">",">","X","=","pd.DataFrame","(","dict","(","x1","=","[","1,2,3,4,5,6","]",",","x2","=","[","``","b","''",",","``","b","''",",","``","b","''",",","``","b","''",",","``","b","''",",","``","a","''","]",")",")",">",">",">","rle","=","RareLabelEncoder","(","n_categories","=","1",",","tol=0.2",")",">",">",">","rle.fit","(","X",")",">",">",">","rle.transform","(","X",")","x1","x2","0","1","b","1","2","b","2","3","b","3","4","b","4","5","b","5","6","Rare"]
docstr: inverse_transform is not implemented for this transformer.
docstr_tok: ["inverse_transform","is","not","implemented","for","this","transformer","."]
code: def inverse_transform(self, X: pd.DataFrame):
      """inverse_transform is not implemented for this transformer."""
      raise NotImplementedError(
          "inverse_transform is not implemented for this transformer."
      )
  
file_path: feature_engine/feature_engine/encoding/rare_label.py
imports: import warnings
  from typing import List, Optional, Union
  import numpy
  import pandas
  from feature_engine._docstrings.fit_attributes import _feature_names_in_docstring, _n_features_in_docstring, _variables_attribute_docstring
  from feature_engine._docstrings.init_parameters import _ignore_format_docstring, _variables_categorical_docstring
  from feature_engine._docstrings.methods import _fit_transform_docstring
  from feature_engine._docstrings.substitute import Substitution
  from feature_engine.dataframe_checks import _check_contains_na, check_X
  from feature_engine.encoding.base_encoder import CategoricalInitMixin, CategoricalMethodsMixin
label_desc: Use image node_id 4 for calling the RareLabelEncoder obj's underlying member method code with example usage: obj.inverse_transform(X) without return types