DataList¶
- class DataList¶
Bases:
object
A class to handle input-output pairs of a black-box function.
Methods
Initialize the data list class.
Append an input-output pair.
Deepcopy an instantce of the class.
Save the data if the filepath is set either in the
DataList.__init__
or with theDataList.set_output_path
method.Set a output file path.
Convert and return the data to
pandas.DataFrame
.Convert to the solution dict.
Convert the i-th data (input) to
StructuredSolution
.Convert the data (all input vectors) to a list of
StructuredSolution
.Attributes
The absolute maximum value in the output values in the current dataset.
Return input vectors and output values.
Names of the variables.
The list of the input vectors.
The list of the output values.
- __getitem__(i: int) tuple[list[bool | int | float], int | float] ¶
Return a tuple of the input vector and output value.
- __init__(
- x: list[list[bool | int | float]] | None = None,
- y: list[int | float] | None = None,
- variable_names: list[str] | None = None,
- filepath: str | None = None,
Initialize the data list class.
- Parameters:
x (list[list[bool | int | float]] | None, optional) – A list of the input vectors. Defaults to None.
y (list[int | float] | None, optional) – A list of the output values. Defaults to None.
variable_names (list[str] | None, optional) – A list of the variable names. Defaults to None.
filepath (str | None, optional) – A filepath to save the data with
save()
method. Defaults to None.
- Raises:
ValueError – If only one of (x, y) is specified.
ValueError – If x and y do not have the same length.
ValueError – If at least one of the data (x, y) or variable_names is not specified.
- __iter__() Iterator[tuple] ¶
A tuple of the input vector and output value.
- Yields:
tuple[list[bool | int | float], int | float] – A tuple of the input vector and output value.
- is_unique(solution_dict: FlatSolutionDict) bool ¶
- save() None ¶
Save the data if the filepath is set either in the
DataList.__init__
or with theDataList.set_output_path
method.
- set_output_path(filepath: str | None) None ¶
Set a output file path.
- Parameters:
filepath (str | None) – A file path.
- to_df() DataFrame ¶
Convert and return the data to
pandas.DataFrame
.- Returns:
The converted data.
- Return type:
pandas.DataFrame
- to_solution_dict(i: int) FlatSolutionDict ¶
Convert to the solution dict. This can be used for multi-objective optimization where there is no one specific
Variables
assigned for the multiple objectives.- Parameters:
i (int) – Index of the sample.
- Returns:
The resulting solution dict.
- Return type:
- to_structured_solution(variables: Variables, i: int) StructuredSolution ¶
Convert the i-th data (input) to
StructuredSolution
.- Parameters:
- Returns:
A converted input vector.
- Return type:
- to_structured_solution_list(variables: Variables) list[StructuredSolution] ¶
Convert the data (all input vectors) to a list of
StructuredSolution
.
- __dict__ = mappingproxy({'__module__': 'amplify_bbopt.data_list', '__doc__': 'A class to handle input-output pairs of a black-box function.', '__init__': <function DataList.__init__>, 'variable_names': <property object>, 'append': <function DataList.append>, '__len__': <function DataList.__len__>, '__getitem__': <function DataList.__getitem__>, '__iter__': <function DataList.__iter__>, 'to_df': <function DataList.to_df>, 'to_solution_dict': <function DataList.to_solution_dict>, 'to_structured_solution': <function DataList.to_structured_solution>, 'to_structured_solution_list': <function DataList.to_structured_solution_list>, 'save': <function DataList.save>, 'set_output_path': <function DataList.set_output_path>, 'is_unique': <function DataList.is_unique>, 'values': <property object>, 'abs_y_max': <property object>, 'x': <property object>, 'y': <property object>, 'copy': <function DataList.copy>, '__dict__': <attribute '__dict__' of 'DataList' objects>, '__weakref__': <attribute '__weakref__' of 'DataList' objects>, '__annotations__': {'_x': 'list[list[bool | int | float]]', '_y': 'list[int | float]'}})¶
- __weakref__¶
list of weak references to the object (if defined)