|
10 | 10 | class Grid: |
11 | 11 | """Generates and manages a grid of hyperparameter settings for GA experiments.""" |
12 | 12 |
|
| 13 | + global_params: global_parameters |
| 14 | + """A reference to the global parameters singleton instance.""" |
| 15 | + |
| 16 | + verbose: int |
| 17 | + """The verbosity level, inherited from global parameters.""" |
| 18 | + |
| 19 | + sample_n: int |
| 20 | + """The number of random settings to sample from the full grid.""" |
| 21 | + |
| 22 | + grid: Dict[str, Union[List, Dict]] |
| 23 | + """ |
| 24 | + The dictionary defining the hyperparameter search space for the GA. |
| 25 | +
|
| 26 | + Keys represent different aspects of the experiment: |
| 27 | + - **weighted**: The weighting strategy for the ensemble. |
| 28 | + - **use_stored_base_learners**: Whether to use pre-trained base learners. |
| 29 | + - **store_base_learners**: Whether to save the base learners after training. |
| 30 | + - **resample**: The resampling strategy to handle class imbalance. |
| 31 | + - **scale**: Whether to apply standard scaling to features. |
| 32 | + - **n_features**: The number of features to use (currently 'all'). |
| 33 | + - **param_space_size**: The size of the hyperparameter space for base learners. |
| 34 | + - **n_unique_out**: A parameter for future use. |
| 35 | + - **outcome_var_n**: The index of the outcome variable to use. |
| 36 | + - **div_p**: A parameter for future use. |
| 37 | + - **percent_missing**: The threshold for dropping columns with missing values. |
| 38 | + - **corr**: The threshold for dropping highly correlated features. |
| 39 | + - **cxpb**: The crossover probability for the genetic algorithm. |
| 40 | + - **mutpb**: The mutation probability for the genetic algorithm. |
| 41 | + - **indpb**: The independent probability for each attribute to be mutated. |
| 42 | + - **t_size**: The tournament size for selection in the genetic algorithm. |
| 43 | + - **data**: A nested dictionary specifying which feature categories to include. |
| 44 | + """ |
| 45 | + |
| 46 | + settings_list: List[Dict] |
| 47 | + """ |
| 48 | + A list of hyperparameter combinations sampled from the `grid`. Each element |
| 49 | + is a dictionary representing one complete experimental configuration. |
| 50 | + """ |
| 51 | + |
| 52 | + settings_list_iterator: it.chain |
| 53 | + """An iterator over the `settings_list`.""" |
| 54 | + |
13 | 55 | def __init__(self, sample_n: Optional[int] = 1000): |
14 | 56 | """Initializes the Grid object for Genetic Algorithms. |
15 | 57 |
|
@@ -110,7 +152,3 @@ def c_prod(d: Union[Dict, List]) -> Generator[Dict, None, None]: |
110 | 152 | self.settings_list = random.sample(self.settings_list, sample_size) |
111 | 153 |
|
112 | 154 | self.settings_list_iterator = iter(self.settings_list) |
113 | | - |
114 | | - # This is likely not properly functioning. Does not return iteration, instead reinitiates. |
115 | | - # Don't need to subsample, can just generate n number of random choices from grid space. |
116 | | - # function can just return random choice from grid space, terminate at the other end once limit reached. |
|
0 commit comments