class_docstr: Simultaneous features selection with RFA and hyperparamater searching
  on a given validation set for LGBModel or XGBModel.
  
  Pass a LGBModel or XGBModel to compute features selection with RFA.
  The gradient boosting instance with the best features is selected.
  When a eval_set is provided, the best gradient boosting and the best
  features are obtained evaluating the score with eval_metric.
  Otherwise, the best combination is obtained looking only at feature
  importance.
  
  If param_grid is a dictionary with parameter boundaries, a hyperparameter
  tuning is computed simultaneously. The parameter combinations are scored on
  the provided eval_set.
  To operate random search pass distributions in the param_grid with rvs
  method for sampling (such as those from scipy.stats.distributions).
  To operate bayesian search pass hyperopt distributions.
  The specification of n_iter or sampling_seed is effective only with random
  or hyperopt searches.
  The best parameter combination is the one which obtain the better score
  (as returned by eval_metric) on the provided eval_set.
  
  If all parameters are presented as a list/floats/integers, grid-search
  is performed. If at least one parameter is given as a distribution (such as
  those from scipy.stats.distributions), random-search is performed computing
  sampling with replacement. Bayesian search is effective only when all the
  parameters to tune are in form of hyperopt distributions.
  It is highly recommended to use continuous distributions for continuous
  parameters.
  
  Parameters
  ----------
  estimator : object
      A supervised learning estimator of LGBModel or XGBModel type.
  
  step : int or float, default=1
      If greater than or equal to 1, then `step` corresponds to the
      (integer) number of features to remove at each iteration.
      If within (0.0, 1.0), then `step` corresponds to the percentage
      (rounded down) of features to remove at each iteration.
      Note that the last iteration may remove fewer than `step` features in
      order to reach `min_features_to_select`.
  
  min_features_to_select : int, default=None
      The minimum number of features to be selected. This number of features
      will always be scored, even if the difference between the original
      feature count and `min_features_to_select` isn't divisible by
      `step`. The default value for min_features_to_select is set to 1 when a
      eval_set is provided, otherwise it always corresponds to n_features // 2.
  
  importance_type : str, default='feature_importances'
       Which importance measure to use. It can be 'feature_importances'
       (the default feature importance of the gradient boosting estimator)
       or 'shap_importances'.
  
  train_importance : bool, default=True
      Effective only when importance_type='shap_importances'.
      Where to compute the shap feature importance: on train (True)
      or on eval_set (False).
  
  param_grid : dict, default=None
      Dictionary with parameters names (`str`) as keys and distributions
      or lists of parameters to try.
      None means no hyperparameters search.
  
  greater_is_better : bool, default=False
      Effective only when hyperparameters searching.
      Whether the quantity to monitor is a score function,
      meaning high is good, or a loss function, meaning low is good.
  
  n_iter : int, default=None
      Effective only when hyperparameters searching.
      Effective only for random or hyperopt serach.
      Number of parameter settings that are sampled.
      n_iter trades off runtime vs quality of the solution.
  
  sampling_seed : int, default=None
      Effective only when hyperparameters searching.
      Effective only for random or hyperopt serach.
      The seed used to sample from the hyperparameter distributions.
  
  n_jobs : int, default=None
      Effective only when hyperparameters searching without hyperopt.
      The number of jobs to run in parallel for model fitting.
      ``None`` means 1 using one processor. ``-1`` means using all
      processors.
  
  verbose : int, default=1
      Verbosity mode. <=0 silent all; ==1 print trial logs (when
      hyperparameters searching); >1 print feature selection logs plus
      trial logs (when hyperparameters searching).
  
  Attributes
  ----------
  estimator_ : estimator
      The fitted estimator with the select features and the optimal
      parameter combination (when hyperparameters searching).
  
  n_features_ : int
      The number of selected features (from the best param config
      when hyperparameters searching).
  
  ranking_ : ndarray of shape (n_features,)
      The feature ranking, such that ``ranking_[i]`` corresponds to the
      ranking position of the i-th feature (from the best param config
      when hyperparameters searching). Selected  features are assigned
      rank 1.
  
  support_ : ndarray of shape (n_features,)
      The mask of selected features (from the best param config
      when hyperparameters searching).
  
  score_history_ : list
      Available only when a eval_set is provided.
      Scores obtained reducing the features (from the best param config
      when hyperparameters searching).
  
  best_params_ : dict
      Available only when hyperparameters searching.
      Parameter setting that gave the best results on the eval_set.
  
  trials_ : list
      Available only when hyperparameters searching.
      A list of dicts. The dicts are all the parameter combinations tried
      and derived from the param_grid.
  
  best_score_ : float
      Available only when hyperparameters searching.
      The best score achieved by all the possible combination created.
  
  scores_ : list
      Available only when hyperparameters searching.
      The scores achieved on the eval_set by all the models tried.
  
  best_iter_ : int
      Available only when hyperparameters searching.
      The boosting iterations achieved by the best parameters combination.
  
  iterations_ : list
      Available only when hyperparameters searching.
      The boosting iterations of all the models tried.
  
  boost_type_ : str
      The type of the boosting estimator (LGB or XGB).
  
  Notes
  -----
  The code for the RFA algorithm is inspired and improved from:
  https://github.com/heberleh/recursive-feature-addition
class_docstr_tok: ["Simultaneous","features","selection","with","RFA","and","hyperparamater","searching","on","a","given","validation","set","for","LGBModel","or","XGBModel",".","Pass","a","LGBModel","or","XGBModel","to","compute","features","selection","with","RFA",".","The","gradient","boosting","instance","with","the","best","features","is","selected",".","When","a","eval_set","is","provided",",","the","best","gradient","boosting","and","the","best","features","are","obtained","evaluating","the","score","with","eval_metric",".","Otherwise",",","the","best","combination","is","obtained","looking","only","at","feature","importance",".","If","param_grid","is","a","dictionary","with","parameter","boundaries",",","a","hyperparameter","tuning","is","computed","simultaneously",".","The","parameter","combinations","are","scored","on","the","provided","eval_set",".","To","operate","random","search","pass","distributions","in","the","param_grid","with","rvs","method","for","sampling","(","such","as","those","from","scipy.stats.distributions",")",".","To","operate","bayesian","search","pass","hyperopt","distributions",".","The","specification","of","n_iter","or","sampling_seed","is","effective","only","with","random","or","hyperopt","searches",".","The","best","parameter","combination","is","the","one","which","obtain","the","better","score","(","as","returned","by","eval_metric",")","on","the","provided","eval_set",".","If","all","parameters","are","presented","as","a","list\/floats\/integers",",","grid-search","is","performed",".","If","at","least","one","parameter","is","given","as","a","distribution","(","such","as","those","from","scipy.stats.distributions",")",",","random-search","is","performed","computing","sampling","with","replacement",".","Bayesian","search","is","effective","only","when","all","the","parameters","to","tune","are","in","form","of","hyperopt","distributions",".","It","is","highly","recommended","to","use","continuous","distributions","for","continuous","parameters",".","Parameters","--","--","--","--","--","estimator",":","object","A","supervised","learning","estimator","of","LGBModel","or","XGBModel","type",".","step",":","int","or","float",",","default=1","If","greater","than","or","equal","to","1",",","then","`","step","`","corresponds","to","the","(","integer",")","number","of","features","to","remove","at","each","iteration",".","If","within","(","0.0",",","1.0",")",",","then","`","step","`","corresponds","to","the","percentage","(","rounded","down",")","of","features","to","remove","at","each","iteration",".","Note","that","the","last","iteration","may","remove","fewer","than","`","step","`","features","in","order","to","reach","`","min_features_to_select","`",".","min_features_to_select",":","int",",","default=None","The","minimum","number","of","features","to","be","selected",".","This","number","of","features","will","always","be","scored",",","even","if","the","difference","between","the","original","feature","count","and","`","min_features_to_select","`","is","n't","divisible","by","`","step","`",".","The","default","value","for","min_features_to_select","is","set","to","1","when","a","eval_set","is","provided",",","otherwise","it","always","corresponds","to","n_features","\/\/","2.","importance_type",":","str",",","default='feature_importances'","Which","importance","measure","to","use",".","It","can","be","'feature_importances'","(","the","default","feature","importance","of","the","gradient","boosting","estimator",")","or","'shap_importances","'",".","train_importance",":","bool",",","default=True","Effective","only","when","importance_type='shap_importances","'",".","Where","to","compute","the","shap","feature","importance",":","on","train","(","True",")","or","on","eval_set","(","False",")",".","param_grid",":","dict",",","default=None","Dictionary","with","parameters","names","(","`","str","`",")","as","keys","and","distributions","or","lists","of","parameters","to","try",".","None","means","no","hyperparameters","search",".","greater_is_better",":","bool",",","default=False","Effective","only","when","hyperparameters","searching",".","Whether","the","quantity","to","monitor","is","a","score","function",",","meaning","high","is","good",",","or","a","loss","function",",","meaning","low","is","good",".","n_iter",":","int",",","default=None","Effective","only","when","hyperparameters","searching",".","Effective","only","for","random","or","hyperopt","serach",".","Number","of","parameter","settings","that","are","sampled",".","n_iter","trades","off","runtime","vs","quality","of","the","solution",".","sampling_seed",":","int",",","default=None","Effective","only","when","hyperparameters","searching",".","Effective","only","for","random","or","hyperopt","serach",".","The","seed","used","to","sample","from","the","hyperparameter","distributions",".","n_jobs",":","int",",","default=None","Effective","only","when","hyperparameters","searching","without","hyperopt",".","The","number","of","jobs","to","run","in","parallel","for","model","fitting",".","``","None","``","means","1","using","one","processor",".","``","-1","``","means","using","all","processors",".","verbose",":","int",",","default=1","Verbosity","mode",".","<","=0","silent","all",";","==1","print","trial","logs","(","when","hyperparameters","searching",")",";",">","1","print","feature","selection","logs","plus","trial","logs","(","when","hyperparameters","searching",")",".","Attributes","--","--","--","--","--","estimator_",":","estimator","The","fitted","estimator","with","the","select","features","and","the","optimal","parameter","combination","(","when","hyperparameters","searching",")",".","n_features_",":","int","The","number","of","selected","features","(","from","the","best","param","config","when","hyperparameters","searching",")",".","ranking_",":","ndarray","of","shape","(","n_features",",",")","The","feature","ranking",",","such","that","``","ranking_","[","i","]","``","corresponds","to","the","ranking","position","of","the","i-th","feature","(","from","the","best","param","config","when","hyperparameters","searching",")",".","Selected","features","are","assigned","rank","1.","support_",":","ndarray","of","shape","(","n_features",",",")","The","mask","of","selected","features","(","from","the","best","param","config","when","hyperparameters","searching",")",".","score_history_",":","list","Available","only","when","a","eval_set","is","provided",".","Scores","obtained","reducing","the","features","(","from","the","best","param","config","when","hyperparameters","searching",")",".","best_params_",":","dict","Available","only","when","hyperparameters","searching",".","Parameter","setting","that","gave","the","best","results","on","the","eval_set",".","trials_",":","list","Available","only","when","hyperparameters","searching",".","A","list","of","dicts",".","The","dicts","are","all","the","parameter","combinations","tried","and","derived","from","the","param_grid",".","best_score_",":","float","Available","only","when","hyperparameters","searching",".","The","best","score","achieved","by","all","the","possible","combination","created",".","scores_",":","list","Available","only","when","hyperparameters","searching",".","The","scores","achieved","on","the","eval_set","by","all","the","models","tried",".","best_iter_",":","int","Available","only","when","hyperparameters","searching",".","The","boosting","iterations","achieved","by","the","best","parameters","combination",".","iterations_",":","list","Available","only","when","hyperparameters","searching",".","The","boosting","iterations","of","all","the","models","tried",".","boost_type_",":","str","The","type","of","the","boosting","estimator","(","LGB","or","XGB",")",".","Notes","--","--","-","The","code","for","the","RFA","algorithm","is","inspired","and","improved","from",":","https",":","\/\/github.com\/heberleh\/recursive-feature-addition"]
docstr: Private method to build model.
docstr_tok: ["Private","method","to","build","model","."]
code: def _build_model(self, params=None):
      """Private method to build model."""
  
      estimator = clone(self.estimator)
  
      if params is None:
          model = _RFA(
              estimator=estimator,
              min_features_to_select=self.min_features_to_select,
              step=self.step,
              greater_is_better=self.greater_is_better,
              importance_type=self.importance_type,
              train_importance=self.train_importance,
              verbose=self.verbose,
          )
  
      else:
          estimator.set_params(**params)
          model = _RFA(
              estimator=estimator,
              min_features_to_select=self.min_features_to_select,
              step=self.step,
              greater_is_better=self.greater_is_better,
              importance_type=self.importance_type,
              train_importance=self.train_importance,
              verbose=self.verbose,
          )
  
      return model
  
imports: from sklearn.base import clone
  from ._classes import _BoostSearch, _Boruta, _RFA, _RFE
label_desc: Use image node_id 2 for calling the BoostRFA obj's underlying member method code with example usage: obj._build_model(params) and returns: model