baybe.surrogates.utils.catch_constant_targets¶
- baybe.surrogates.utils.catch_constant_targets(cls: type[_TSurrogate], std_threshold: float = 1e-06)[source]¶
Make a
Surrogateclass robustly handle constant training targets.- More specifically, “constant training targets” can mean either of:
The standard deviation of the training targets is below the given threshold.
There is only one target and the standard deviation cannot even be computed.
The modified class handles the above cases separately from “regular operation” by resorting to a
baybe.surrogates.naive.MeanPredictionSurrogate, which is stored outside the model in a dictionary maintained by this decorator.- Parameters:
- Return type:
- Returns:
The modified class.