ml_grid.util.grid_param_space_ga

Defines the Grid class for creating a hyperparameter search space for GA.

Classes

Grid

Initializes the Grid object for Genetic Algorithms.

Module Contents

class ml_grid.util.grid_param_space_ga.Grid(sample_n: int | None = 1000)[source]

Initializes the Grid object for Genetic Algorithms.

This class creates a comprehensive grid of settings by taking the Cartesian product of all specified hyperparameters. It then randomly samples a specified number of these settings to create a manageable list for experimentation.

Parameters:

sample_n (Optional[int], optional) – The number of random settings to sample from the full grid. Defaults to 1000.

global_params: ml_grid.util.global_params.global_parameters[source]

A reference to the global parameters singleton instance.

verbose: int[source]

The verbosity level, inherited from global parameters.

sample_n: int[source]

The number of random settings to sample from the full grid.

grid: Dict[str, List | Dict][source]

The dictionary defining the hyperparameter search space for the GA.

Keys represent different aspects of the experiment: - weighted: The weighting strategy for the ensemble. - use_stored_base_learners: Whether to use pre-trained base learners. - store_base_learners: Whether to save the base learners after training. - resample: The resampling strategy to handle class imbalance. - scale: Whether to apply standard scaling to features. - n_features: The number of features to use (currently ‘all’). - param_space_size: The size of the hyperparameter space for base learners. - n_unique_out: A parameter for future use. - outcome_var_n: The index of the outcome variable to use. - div_p: A parameter for future use. - percent_missing: The threshold for dropping columns with missing values. - corr: The threshold for dropping highly correlated features. - cxpb: The crossover probability for the genetic algorithm. - mutpb: The mutation probability for the genetic algorithm. - indpb: The independent probability for each attribute to be mutated. - t_size: The tournament size for selection in the genetic algorithm. - data: A nested dictionary specifying which feature categories to include.

settings_list: List[Dict][source]

A list of hyperparameter combinations sampled from the grid. Each element is a dictionary representing one complete experimental configuration.

settings_list_iterator: itertools.chain[source]

An iterator over the settings_list.