test_ml
summary
Given a list of experiments, where each experiment is a dictionary that maps fold_idx to a completed w&b sweep, this script ought to 1. take the best hyperparameters from each fold (sweep) or from a designated run_id if requested, 2. fit the model on that fold, 3. save test predictions to file.
Experiment
dataclass
Class representing an experiment.
Source code in src/run/single_run/test_ml.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
load_sweep_ids_from_yaml(yaml_path)
Load sweep IDs from a YAML file.
Source code in src/run/single_run/test_ml.py
197 198 199 200 201 202 203 | |
HyperArgs
Bases: Tap
Command line arguments for the script.
Source code in src/run/single_run/test_ml.py
156 157 158 159 160 161 162 163 164 | |
Sweep
dataclass
Class representing a sweep in wandb.
Attributes:
| Name | Type | Description |
|---|---|---|
sweep_id |
str
|
The ID of the sweep in wandb. |
cfg_of_best |
dict
|
The configuration of the best run in the sweep. |
fold_index |
int | None
|
The index of the fold, if applicable. |
Source code in src/run/single_run/test_ml.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
checks(experiments_list)
Basic consistency check: ensure that each sweep_id is unique across experiments.
Source code in src/run/single_run/test_ml.py
247 248 249 250 251 252 | |
get_config_from_run(api, entity, project, run_id)
Fetches the config of a single run by run_id.
Source code in src/run/single_run/test_ml.py
238 239 240 241 242 243 244 | |
get_config_from_sweep(api, entity, project, sweep_id)
Fetches the config of the best run (by the sweep's objective) from a given sweep_id.
Source code in src/run/single_run/test_ml.py
224 225 226 227 228 229 230 231 232 233 234 235 | |
predict_on_val_and_test(model, val_datasets, test_datasets)
Predict on all val and test datasets, returning one list of results.
Source code in src/run/single_run/test_ml.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
process_results(results, dm, cfg, fold_index)
Given all results from val and test datasets, build a unified DataFrame with all relevant columns.
TODO almost duplicate code with test_dl.py
Source code in src/run/single_run/test_ml.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |