Dataset

class Dataset

Bases: object

Represents a dataset for surrogate model training.

Methods

__init__

Initializes a dataset for surrogate model training.

append

Appends a new data point to the dataset.

empty

Creates an empty dataset for surrogate model training.

find

Finds the index of a data point in the dataset.

Attributes

x

Returns the input features of the dataset, flattened.

y

Returns the target values of the dataset.

__init__(x: ndarray, y: ndarray) None

Initializes a dataset for surrogate model training.

Parameters:
  • x (np.ndarray) – The input features (must be flattened).

  • y (np.ndarray) – The target values.

__iter__() zip[tuple[NDArray[np.float64], float]]
__len__() int
append(x: ndarray, y: float | ndarray) None

Appends a new data point to the dataset.

Parameters:
  • x (np.ndarray) – The input features (must be flattened).

  • y (float | np.ndarray) – The target value(s).

classmethod empty(num_variables: int) Dataset

Creates an empty dataset for surrogate model training.

Parameters:

num_variables (int) – The number of input variables.

Returns:

An empty dataset.

Return type:

Dataset

find(x: NDArray[np.float64]) int | None

Finds the index of a data point in the dataset.

Parameters:

x (NDArray[np.float64]) – The input features of the data point to find.

Raises:
  • ValueError – If the input shape is not 1-dimensional or does not match the number of features in the model.

  • ValueError – If the input features do not match any data point in the dataset.

Returns:

The index of the data point in the dataset, or None if not found.

Return type:

int | None

__dict__ = mappingproxy({'__module__': 'amplify_bbopt.trainer', '__doc__': 'Represents a dataset for surrogate model training.', '__init__': <function Dataset.__init__>, '_check': <function Dataset._check>, 'empty': <classmethod(<function Dataset.empty>)>, 'append': <function Dataset.append>, 'x': <property object>, 'y': <property object>, '__len__': <function Dataset.__len__>, '__iter__': <function Dataset.__iter__>, 'find': <function Dataset.find>, '__dict__': <attribute '__dict__' of 'Dataset' objects>, '__weakref__': <attribute '__weakref__' of 'Dataset' objects>, '__annotations__': {'_x': 'NDArray[np.float64]', '_y': 'NDArray[np.float64]'}})
__weakref__

list of weak references to the object (if defined)

property x: NDArray[np.float64]

Returns the input features of the dataset, flattened.

property y: NDArray[np.float64]

Returns the target values of the dataset.