class_docstr: The RandomSampleImputer() replaces missing data with a random sample extracted from
  the variables in the training set.
  
  The RandomSampleImputer() works with both numerical and categorical variables.
  
  **Note**
  
  The Random samples used to replace missing values may vary from execution to
  execution. This may affect the results of your work. Thus, it is advisable to set a
  seed.
  
  More details in the :ref:`User Guide <random_sample_imputer>`.
  
  Parameters
  ----------
  variables: list, default=None
      The list of variables to be imputed. If None, the imputer will select
      all variables in the train set.
  
  random_state: int, str or list, default=None
      The random_state can take an integer to set the seed when extracting the
      random samples. Alternatively, it can take a variable name or a list of
      variables, which values will be used to determine the seed, observation per
      observation.
  
  seed: str, default='general'
      Indicates whether the seed should be set for each observation with missing
      values, or if one seed should be used to impute all observations in one go.
  
      **'general'**: one seed will be used to impute the entire dataframe. This is
      equivalent to setting the seed in pandas.sample(random_state).
  
      **'observation'**: the seed will be set for each observation using the values
      of the variables indicated in the random_state for that particular
      observation.
  
  seeding_method: str, default='add'
      If more than one variable are indicated to seed the random sampling per
      observation, you can choose to combine those values as an addition or a
      multiplication. Can take the values 'add' or 'multiply'.
  
  Attributes
  ----------
  X_:
      Copy of the training dataframe from which to extract the random samples.
  
  {variables_}
  
  {feature_names_in_}
  
  {n_features_in_}
  
  Methods
  -------
  fit:
      Make a copy of the train set
  
  {fit_transform}
  
  {transform}
  
  Examples
  --------
  
  >>> import pandas as pd
  >>> import numpy as np
  >>> from feature_engine.imputation import RandomSampleImputer
  >>> X = pd.DataFrame(dict(
  >>>        x1 = [np.nan,1,1,0,np.nan],
  >>>        x2 = ["a", np.nan, "b", np.nan, "a"],
  >>>        ))
  >>> rsi = RandomSampleImputer()
  >>> rsi.fit(X)
  >>> rsi.transform(X)
      x1 x2
  0  1.0  a
  1  1.0  b
  2  1.0  b
  3  0.0  a
  4  1.0  a
class_docstr_tok: ["The","RandomSampleImputer","(",")","replaces","missing","data","with","a","random","sample","extracted","from","the","variables","in","the","training","set",".","The","RandomSampleImputer","(",")","works","with","both","numerical","and","categorical","variables",".","*","*","Note","*","*","The","Random","samples","used","to","replace","missing","values","may","vary","from","execution","to","execution",".","This","may","affect","the","results","of","your","work",".","Thus",",","it","is","advisable","to","set","a","seed",".","More","details","in","the",":","ref",":","`","User","Guide","<","random_sample_imputer",">","`",".","Parameters","--","--","--","--","--","variables",":","list",",","default=None","The","list","of","variables","to","be","imputed",".","If","None",",","the","imputer","will","select","all","variables","in","the","train","set",".","random_state",":","int",",","str","or","list",",","default=None","The","random_state","can","take","an","integer","to","set","the","seed","when","extracting","the","random","samples",".","Alternatively",",","it","can","take","a","variable","name","or","a","list","of","variables",",","which","values","will","be","used","to","determine","the","seed",",","observation","per","observation",".","seed",":","str",",","default='general'","Indicates","whether","the","seed","should","be","set","for","each","observation","with","missing","values",",","or","if","one","seed","should","be","used","to","impute","all","observations","in","one","go",".","*","*","'general","'","*","*",":","one","seed","will","be","used","to","impute","the","entire","dataframe",".","This","is","equivalent","to","setting","the","seed","in","pandas.sample","(","random_state",")",".","*","*","'observation","'","*","*",":","the","seed","will","be","set","for","each","observation","using","the","values","of","the","variables","indicated","in","the","random_state","for","that","particular","observation",".","seeding_method",":","str",",","default='add'","If","more","than","one","variable","are","indicated","to","seed","the","random","sampling","per","observation",",","you","can","choose","to","combine","those","values","as","an","addition","or","a","multiplication",".","Can","take","the","values","'add","'","or","'multiply","'",".","Attributes","--","--","--","--","--","X_",":","Copy","of","the","training","dataframe","from","which","to","extract","the","random","samples",".","{","variables_","}","{","feature_names_in_","}","{","n_features_in_","}","Methods","--","--","--","-","fit",":","Make","a","copy","of","the","train","set","{","fit_transform","}","{","transform","}","Examples","--","--","--","--",">",">",">","import","pandas","as","pd",">",">",">","import","numpy","as","np",">",">",">","from","feature_engine.imputation","import","RandomSampleImputer",">",">",">","X","=","pd.DataFrame","(","dict","(",">",">",">","x1","=","[","np.nan,1,1,0",",","np.nan","]",",",">",">",">","x2","=","[","``","a","''",",","np.nan",",","``","b","''",",","np.nan",",","``","a","''","]",",",">",">",">",")",")",">",">",">","rsi","=","RandomSampleImputer","(",")",">",">",">","rsi.fit","(","X",")",">",">",">","rsi.transform","(","X",")","x1","x2","0","1.0","a","1","1.0","b","2","1.0","b","3","0.0","a","4","1.0","a"]
code: def __init__(
      self,
      variables: Union[None, int, str, List[Union[str, int]]] = None,
      random_state: Union[None, int, str, List[Union[str, int]]] = None,
      seed: str = "general",
      seeding_method: str = "add",
  ) -> None:
      if seed not in ["general", "observation"]:
          raise ValueError(
              "seed takes only values 'general' or 'observation'"
          )
  
      if seeding_method not in ["add", "multiply"]:
          raise ValueError(
              "seeding_method takes only values 'add' or 'multiply'"
          )
  
      if seed == "general" and random_state:
          if not isinstance(random_state, int):
              raise ValueError(
                  "if seed == 'general' then random_state must take an integer"
              )
  
      if seed == "observation" and not random_state:
          raise ValueError(
              "if seed == 'observation' the random state must take the name of one "
              "or more variables which will be used to seed the imputer"
          )
  
      self.variables = _check_init_parameter_variables(variables)
      self.random_state = random_state
      self.seed = seed
      self.seeding_method = seeding_method
  
file_path: feature_engine/feature_engine/imputation/random_sample.py
imports: 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.methods import _fit_transform_docstring
  from feature_engine._docstrings.substitute import Substitution
  from feature_engine._variable_handling.init_parameter_checks import _check_init_parameter_variables
  from feature_engine._variable_handling.variable_type_selection import _find_all_variables
  from feature_engine.dataframe_checks import check_X
  from feature_engine.imputation.base_imputer import BaseImputer
  from feature_engine.tags import _return_tags
label_desc: Use image node_id 1 to create a new RandomSampleImputer object from inherited base classes: BaseImputer with example: obj = RandomSampleImputer(variables, random_state, seed, seeding_method)