saealib.SurrogatePrediction#
- class saealib.SurrogatePrediction(channels, x=None, label=None, metadata=<factory>)[source]#
Bases:
objectUnified return type for surrogate model predictions.
channelsis the canonical representation: one namedPredictionChannelper prediction output (e.g."objective","win_rate").value/stdare convenience properties delegating to the"objective"channel and raiseKeyErrorwhen it is absent.- Parameters:
channels (dict[str, PredictionChannel])
x (ndarray | None)
label (ndarray | None)
metadata (dict[str, object])
- channels#
Named prediction channels. Channel names are unique, non-empty strings.
- Type:
dict[str, PredictionChannel]
- x#
The query points passed to
predict(). shape: (n_samples, n_features). None unless the surrogate populates it. Needed by acquisition functions that have no other channel to the points being scored (e.g.CORSDistance).- Type:
np.ndarray or None
- label#
Predicted class labels. shape: (n_samples,). None unless the surrogate is a classification model.
- Type:
np.ndarray or None
- metadata#
Implementation-specific additional information (e.g., SHAP values, gradient estimates).
- Type:
dict
Methods
Build a single- |
|
Project a single named channel into a standalone |
Method Details
- SurrogatePrediction.__init__(channels, x=None, label=None, metadata=<factory>)#
- Parameters:
channels (dict[str, PredictionChannel])
x (ndarray | None)
label (ndarray | None)
metadata (dict[str, object])
- Return type:
None
- classmethod SurrogatePrediction.objective(value, std=None, x=None, metadata=None)[source]#
Build a single-
"objective"-channelSurrogatePrediction.Equivalent to constructing
channels={"objective": PredictionChannel(value, std)}by hand.- Parameters:
value (ndarray)
std (ndarray | None)
x (ndarray | None)
metadata (dict[str, object] | None)
- Return type:
- SurrogatePrediction.select_channel(name, *, as_objective=True)[source]#
Project a single named channel into a standalone
SurrogatePrediction.- Parameters:
name (str) – Channel name to select. Raises
KeyErrorif not present inself.channels.as_objective (bool, optional) – If True (default), the result’s
channelsis{"objective": self.channels[name]}so.value/.stdresolve normally. If False, the result’schannelsis{name: self.channels[name]}, preserving the original name for callers that want to project without claiming the channel is the objective.
- Returns:
A new prediction carrying forward
self.xandself.metadataunchanged. The selectedPredictionChannel(with its owncovariance/samples) is reused, not copied.- Return type: