Picks argmax(mean(env_out_acc for env in train_envs))
| 73 | } |
| 74 | |
| 75 | class IIDAccuracySelectionMethod(SelectionMethod): |
| 76 | """Picks argmax(mean(env_out_acc for env in train_envs))""" |
| 77 | name = "training-domain validation set" |
| 78 | |
| 79 | @classmethod |
| 80 | def _step_acc(self, record): |
| 81 | """Given a single record, return a {val_acc, test_acc} dict.""" |
| 82 | test_env = record['args']['test_envs'][0] |
| 83 | val_env_keys = [] |
| 84 | for i in itertools.count(): |
| 85 | if f'env{i}_out_acc' not in record: |
| 86 | break |
| 87 | if i != test_env: |
| 88 | val_env_keys.append(f'env{i}_out_acc') |
| 89 | test_in_acc_key = 'env{}_in_acc'.format(test_env) |
| 90 | return { |
| 91 | 'val_acc': np.mean([record[key] for key in val_env_keys]), |
| 92 | 'test_acc': record[test_in_acc_key] |
| 93 | } |
| 94 | |
| 95 | @classmethod |
| 96 | def run_acc(self, run_records): |
| 97 | test_records = get_test_records(run_records) |
| 98 | if not len(test_records): |
| 99 | return None |
| 100 | return test_records.map(self._step_acc).argmax('val_acc') |
| 101 | |
| 102 | class LeaveOneOutSelectionMethod(SelectionMethod): |
| 103 | """Picks (hparams, step) by leave-one-out cross validation.""" |
nothing calls this directly
no outgoing calls
no test coverage detected