Surrogate

The Surrogate approximates expensive experimental evaluation by wrapping a BaseModel. It provides training functionality to fit the model on labelled training data, prediction capabilities to make predictions on candidate sequences, and a featurise() method that delegates to the underlying model to obtain feature embeddings — used by diversity-based acquisition functions such as CoreSet. The surrogate is a key component in active learning, enabling efficient exploration by reducing the need for costly experimental evaluations.

class alf_core.surrogate.surrogate.Surrogate(model)[source]

Bases: object

Surrogate model is fine-tuned during the active learning process on the acquired candidates. Any BaseModel child class can be used as a surrogate model.

featurise(inputs)[source]

Featurise the given inputs using the surrogate model’s featurisation method.

Parameters:

inputs (list[Candidate]) – List of Candidate objects or a LabelledCandidates instance to featurise.

Return type:

Any

Returns:

Feature representation from the underlying model, typically an np.ndarray or torch.Tensor.

fit(train_data, val_data)[source]

Fit the surrogate model on training and validation data.

Parameters:
Return type:

list[SurrogateEpochMetrics]

Returns:

List of SurrogateEpochMetrics, one per epoch trained. Empty if the underlying model does not track per-epoch metrics.

get_training_summary_metrics()[source]

Get summary metrics from the most recent training run.

Return type:

dict[str, Union[float, int, number]]

Returns:

Dictionary of metric names to values from the underlying model’s training.

predict(candidates)[source]

Predict scores for the given candidates.

Parameters:

candidates (list[Candidate]) – List of Candidate objects to make predictions for.

Return type:

Predictions

Returns:

Predictions object containing means and optionally variances and empirical distributions.

setup(dataset)[source]

Configure the surrogate model for the given dataset.

Parameters:

dataset (BaseDataset) – The dataset this surrogate will be trained on.

Return type:

None