Predictions

The Predictions dataclass stores model predictions including mean predictions and uncertainty estimates. This is returned by surrogate models and used for acquisition scoring.

The to_dataframe() method requires a problem_type argument to determine the output format: regression predictions produce mean and variance columns, while classification predictions produce one prob_class_N column per class (e.g., prob_class_0, prob_class_1).

class alf_core.dataclasses.predictions.Predictions(means, variances=None, empirical_dist=None)[source]

Bases: object

A data class for storing and managing predictions from a model.

means

A numpy array of mean predictions across all candidates.

variances

An optional numpy array of prediction variances, representing the model’s uncertainty for each prediction.

empirical_dist

An optional 2D numpy array containing predictions from individual models in an ensemble. Typically has the shape (num_candidates, num_ensemble_models).

empirical_dist: ndarray | None = None
means: ndarray
to_dataframe(candidates, targets, problem_type)[source]

Convert predictions to a DataFrame.

Creates a DataFrame with predictions, targets, and optionally variances and ensemble predictions.

Parameters:
  • candidates (list[Candidate]) – List of Candidate objects corresponding to the predictions.

  • targets (ndarray) – Ground truth target values corresponding to each candidate.

  • problem_type (ProblemType) – ProblemType to determine the predictions type.

Return type:

DataFrame

Returns:

A DataFrame with predictions, targets, and optionally variances and ensemble predictions.

variances: ndarray | None = None