pysr3.lme.model_selectors module

Black-box routines for automatic feature selection for mixed-models.

pysr3.lme.model_selectors.get_model(model: str, problem: LMEProblem)

Takes the name of the model. Returns the constructor for it, as well as a suitable parameter grid for various sparsity levels.

Parameters:
  • model (str) – a name of a model

  • problem (LMEProblem) – an instance of the problem

Returns:

  • constructor (function: params -> model(**params)) – model constructor

  • selection_spectrum (Dict[str, float]) – points for parameter grid search

pysr3.lme.model_selectors.select_covariates(df: DataFrame, target: str, variance: str, group: str, covs: Dict[str, List[str]] | None = None, pre_sel_covs: Dict[str, List[str]] | None = None, output_folder: str | Path = '.', model_name: str = 'L1_SR3', **kwargs) None

Implements black-box functionality for selecting most important fixed and random features in Linear Mixed-Effect Models.

Parameters:
  • df (pd.DataFrame) – Data frame contains all the necessary columns.

  • target (str) – Column name of observation.

  • variance (str) – Column name of the observation variances

  • group (str) – Column name of the group, usually specified as study_id.

  • covs (Optional[Dict[str, List[str]]]) – Dictionary contains all the covariate candidates. Keys of the dictionary are fixed_effects and random_effects, and corresponding value is a list of covariates names which can be empty. Default to None, and when covs is None, it will be automatically parsed as Dictionary with empty list as values.

  • pre_sel_covs (Optional[Dict[str, List[str]]]) – Same structure with covs. Default to None.

  • output_folder (Union[str, Path]) – Path for output folder to store the results. Default to “.”.

  • model_name (str) – which model to use. Can be “L0”, “L0_SR3”, “L1”, “L1_SR3”, “CAD”, “CAD_SR3”, “SCAD”, “SCAD_SR3”

Returns:

None – Return nothing. Store a yaml file contains selected fixed and random effects and all other diagnostic figures.