Create a callback that records the evaluation history into ``eval_result``. Parameters ---------- eval_result : dict A dictionary to store the evaluation results. Returns ------- callback : function The callback that records the evaluation history into the pa
(eval_result)
| 76 | |
| 77 | |
| 78 | def record_evaluation(eval_result): |
| 79 | """Create a callback that records the evaluation history into ``eval_result``. |
| 80 | |
| 81 | Parameters |
| 82 | ---------- |
| 83 | eval_result : dict |
| 84 | A dictionary to store the evaluation results. |
| 85 | |
| 86 | Returns |
| 87 | ------- |
| 88 | callback : function |
| 89 | The callback that records the evaluation history into the passed dictionary. |
| 90 | """ |
| 91 | if not isinstance(eval_result, dict): |
| 92 | raise TypeError('eval_result should be a dictionary') |
| 93 | eval_result.clear() |
| 94 | |
| 95 | def _init(env): |
| 96 | for data_name, eval_name, _, _ in env.evaluation_result_list: |
| 97 | eval_result.setdefault(data_name, collections.OrderedDict()) |
| 98 | eval_result[data_name].setdefault(eval_name, []) |
| 99 | |
| 100 | def _callback(env): |
| 101 | if not eval_result: |
| 102 | _init(env) |
| 103 | for data_name, eval_name, result, _ in env.evaluation_result_list: |
| 104 | eval_result[data_name][eval_name].append(result) |
| 105 | _callback.order = 20 |
| 106 | return _callback |
| 107 | |
| 108 | |
| 109 | def reset_parameter(**kwargs): |