saealib.ManagerSwitcher#

class saealib.ManagerSwitcher(primary, fallback, *, metric='spearman', threshold=0.5)[source]#

Bases: AccuracyBasedSurrogateSwitcher[SurrogateManager]

Switch between two surrogate managers based on an accuracy threshold.

Returns primary when metric >= threshold, fallback otherwise, including when accuracy is unavailable or the metric is non-finite.

Parameters:
  • primary (SurrogateManager) – Manager used when accuracy is satisfactory.

  • fallback (SurrogateManager) – Manager used when accuracy is poor or not yet available.

  • metric (str) – Metric key in SurrogateAccuracy. Default: "spearman".

  • threshold (float) – Minimum acceptable metric value. Default: 0.5.

Methods

__init__

contract

Return the manager-switcher contract.

switch

Return primary or fallback based on the metric threshold.

Method Details

ManagerSwitcher.__init__(primary, fallback, *, metric='spearman', threshold=0.5)[source]#
Parameters:
Return type:

None

ManagerSwitcher.contract()[source]#

Return the manager-switcher contract.

Return type:

ComponentContract

ManagerSwitcher.switch(accuracy)[source]#

Return primary or fallback based on the metric threshold.

Parameters:

accuracy (SurrogateAccuracy | None)

Return type:

SurrogateManager