saealib.GenCtrlSwitcher#
- class saealib.GenCtrlSwitcher(*, gm_max=5, gm_min=0, update_rate=0.5, metric='spearman', initial_error=0.5)[source]#
Bases:
AccuracyBasedSurrogateSwitcher[int]Adjust gen_ctrl via exponential smoothing (Repický et al., 2017).
The surrogate error is estimated from an accuracy metric, exponentially smoothed, then linearly mapped to gen_ctrl:
\[ \begin{align}\begin{aligned}\varepsilon_t = (1-r_u)\varepsilon_{t-1} + r_u\varepsilon_{\text{new}}\\g_m = \operatorname{round}((1-\varepsilon_t) \cdot g_{m,\max})\end{aligned}\end{align} \]For Spearman rho and R2,
epsilon = 0.5 * (1 - value)maps the metric to[0, 1]. For RMSE the value is used directly (assumed to be in[0, 1]). When accuracy is unavailable the smoothed state is unchanged and the current estimate is returned.- Parameters:
gm_max (int) – Upper bound for gen_ctrl. Default:
5.gm_min (int) – Lower bound for gen_ctrl. Default:
0.update_rate (float) – Smoothing rate
r_uin (0, 1]. Default:0.5.metric (str) – Metric key. Default:
"spearman".initial_error (float) – Initial smoothed error before the first observation. Default:
0.5(neutral).
- smoothed_error#
Current exponentially smoothed error estimate. Inspect to monitor the internal state during an
iterate()run.- Type:
float
Methods
Method Details
- GenCtrlSwitcher.__init__(*, gm_max=5, gm_min=0, update_rate=0.5, metric='spearman', initial_error=0.5)[source]#
- Parameters:
gm_max (int)
gm_min (int)
update_rate (float)
metric (str)
initial_error (float)
- Return type:
None
- GenCtrlSwitcher.switch(accuracy)[source]#
Update smoothed error and return new gen_ctrl.
- Parameters:
accuracy (SurrogateAccuracy | None)
- Return type:
int