docstr: Stores information and methods surrounding how mean matching should
  behave for each variable. This class is responsible for determining:
  
  * The mean matching function
  * How predictions are obtained from a lightgbm model
  * The datatype of the predictions
  * The number of mean matching candidates
  * Which variables will have candidate predictions compiled
  
  During the imputation process, the following series of events occur
  for each variable:
  
  1) ImputationKernel trains a lightgbm model
  2) MeanMatchScheme gets predictions from lightgbm model based on the model objective.
  3) MeanMatchScheme performs mean matching on the predictions.
  
  Parameters
  ----------
  mean_match_candidates: int or dict, default = 5
      The number of mean matching candidates to pull.
      One of these candidates will be chosen randomly
      as the imputation value. To skip mean matching,
      set to 0.
  
      If int, that value is used for all variables.
  
      If a dict is passed, it should be of the form:
      {variable: int} pairs. Any variables not specified
      will use the default. Variables can be passed as
      column names or indexes.
  
      For more information about mean matching, see:
      https://github.com/AnotherSamWilson/miceforest#Predictive-Mean-Matching
  
  mean_match_functions: dict
      A dict of {objective: callable} pairs. The objective should be
      a lightgbm objective. The provided function will be used to
      perform mean matching for all models with the given objective.
  
      RULES FOR FUNCTIONS:
          1) The only arguments allowed are those listed in
             miceforest.mean_match_schemes.AVAILABLE_MEAN_MATCH_ARGS
          2) Not all of those arguments are required, the process
             will only pass arguments that the function requires
  
  lgb_model_pred_functions: dict
      A dict of {objective: callable} pairs. The objective should be
      a lightgbm objective. The provided function will be used to
      obtain predictions from lightgbm models with the paired objective.
  
      For example, passing: {"binary": func, "regression": func2} will call
      func(model, data) to obtain the predictions from the model, if the
      model objective was binary.
  
  objective_pred_dtypes: dict
      A dict of {objective: np.datatype} pairs.
      Datatype must be the string datatype name, i.e. "float32"
      How prediction data types will be cast. Casting to a smaller bit
      value can be beneficial when compiling candidates. Depending on
      the data, smaller bit rates tend to result in imputations of
      sufficient quality, while taking up much less space.
docstr_tok: ["Stores","information","and","methods","surrounding","how","mean","matching","should","behave","for","each","variable",".","This","class","is","responsible","for","determining",":","*","The","mean","matching","function","*","How","predictions","are","obtained","from","a","lightgbm","model","*","The","datatype","of","the","predictions","*","The","number","of","mean","matching","candidates","*","Which","variables","will","have","candidate","predictions","compiled","During","the","imputation","process",",","the","following","series","of","events","occur","for","each","variable",":","1",")","ImputationKernel","trains","a","lightgbm","model","2",")","MeanMatchScheme","gets","predictions","from","lightgbm","model","based","on","the","model","objective",".","3",")","MeanMatchScheme","performs","mean","matching","on","the","predictions",".","Parameters","--","--","--","--","--","mean_match_candidates",":","int","or","dict",",","default","=","5","The","number","of","mean","matching","candidates","to","pull",".","One","of","these","candidates","will","be","chosen","randomly","as","the","imputation","value",".","To","skip","mean","matching",",","set","to","0",".","If","int",",","that","value","is","used","for","all","variables",".","If","a","dict","is","passed",",","it","should","be","of","the","form",":","{","variable",":","int","}","pairs",".","Any","variables","not","specified","will","use","the","default",".","Variables","can","be","passed","as","column","names","or","indexes",".","For","more","information","about","mean","matching",",","see",":","https",":","\/\/github.com\/AnotherSamWilson\/miceforest","#","Predictive-Mean-Matching","mean_match_functions",":","dict","A","dict","of","{","objective",":","callable","}","pairs",".","The","objective","should","be","a","lightgbm","objective",".","The","provided","function","will","be","used","to","perform","mean","matching","for","all","models","with","the","given","objective",".","RULES","FOR","FUNCTIONS",":","1",")","The","only","arguments","allowed","are","those","listed","in","miceforest.mean_match_schemes.AVAILABLE_MEAN_MATCH_ARGS","2",")","Not","all","of","those","arguments","are","required",",","the","process","will","only","pass","arguments","that","the","function","requires","lgb_model_pred_functions",":","dict","A","dict","of","{","objective",":","callable","}","pairs",".","The","objective","should","be","a","lightgbm","objective",".","The","provided","function","will","be","used","to","obtain","predictions","from","lightgbm","models","with","the","paired","objective",".","For","example",",","passing",":","{","``","binary","''",":","func",",","``","regression","''",":","func2","}","will","call","func","(","model",",","data",")","to","obtain","the","predictions","from","the","model",",","if","the","model","objective","was","binary",".","objective_pred_dtypes",":","dict","A","dict","of","{","objective",":","np.datatype","}","pairs",".","Datatype","must","be","the","string","datatype","name",",","i.e",".","``","float32","''","How","prediction","data","types","will","be","cast",".","Casting","to","a","smaller","bit","value","can","be","beneficial","when","compiling","candidates",".","Depending","on","the","data",",","smaller","bit","rates","tend","to","result","in","imputations","of","sufficient","quality",",","while","taking","up","much","less","space","."]
code: def __init__(
      self,
      mean_match_candidates: _t_mmc,
      mean_match_functions: _t_obj_func,
      lgb_model_pred_functions: _t_obj_func,
      objective_pred_dtypes: Dict[str, str],
  ):
      """
      Stores information and methods surrounding how mean matching should
      behave for each variable. This class is responsible for determining:
  
      * The mean matching function
      * How predictions are obtained from a lightgbm model
      * The datatype of the predictions
      * The number of mean matching candidates
      * Which variables will have candidate predictions compiled
  
      During the imputation process, the following series of events occur
      for each variable:
  
      1) ImputationKernel trains a lightgbm model
      2) MeanMatchScheme gets predictions from lightgbm model based on the model objective.
      3) MeanMatchScheme performs mean matching on the predictions.
  
      Parameters
      ----------
      mean_match_candidates: int or dict, default = 5
          The number of mean matching candidates to pull.
          One of these candidates will be chosen randomly
          as the imputation value. To skip mean matching,
          set to 0.
  
          If int, that value is used for all variables.
  
          If a dict is passed, it should be of the form:
          {variable: int} pairs. Any variables not specified
          will use the default. Variables can be passed as
          column names or indexes.
  
          For more information about mean matching, see:
          https://github.com/AnotherSamWilson/miceforest#Predictive-Mean-Matching
  
      mean_match_functions: dict
          A dict of {objective: callable} pairs. The objective should be
          a lightgbm objective. The provided function will be used to
          perform mean matching for all models with the given objective.
  
          RULES FOR FUNCTIONS:
              1) The only arguments allowed are those listed in
                 miceforest.mean_match_schemes.AVAILABLE_MEAN_MATCH_ARGS
              2) Not all of those arguments are required, the process
                 will only pass arguments that the function requires
  
      lgb_model_pred_functions: dict
          A dict of {objective: callable} pairs. The objective should be
          a lightgbm objective. The provided function will be used to
          obtain predictions from lightgbm models with the paired objective.
  
          For example, passing: {"binary": func, "regression": func2} will call
          func(model, data) to obtain the predictions from the model, if the
          model objective was binary.
  
      objective_pred_dtypes: dict
          A dict of {objective: np.datatype} pairs.
          Datatype must be the string datatype name, i.e. "float32"
          How prediction data types will be cast. Casting to a smaller bit
          value can be beneficial when compiling candidates. Depending on
          the data, smaller bit rates tend to result in imputations of
          sufficient quality, while taking up much less space.
  
      """
  
      self.mean_match_functions: Dict[str, Callable] = {}
      self.objective_args: Dict[str, Set[str]] = {}
      self.objective_pred_funcs: Dict[str, Callable] = {}
      self.objective_pred_dtypes = objective_pred_dtypes.copy()
  
      for objective, function in mean_match_functions.items():
          self._add_mmf(objective, function)
  
      for objective, function in lgb_model_pred_functions.items():
          self._add_lgbpred(objective, function)
  
      self.mean_match_candidates = mean_match_candidates
      self._mmc_formatted = False
  
file_path: miceforest/miceforest/MeanMatchScheme.py
imports: from .compat import pd_DataFrame
  import inspect
  from copy import deepcopy
  from typing import Callable, Union, Dict, Set
  from numpy import dtype
label_desc: Use image node_id 1 to create a new MeanMatchScheme object  with example: obj = MeanMatchScheme(mean_match_candidates, mean_match_functions, lgb_model_pred_functions, objective_pred_dtypes)