baybe.utils.dataframe.arrays_to_dataframes

baybe.utils.dataframe.arrays_to_dataframes(input_labels: Sequence[str], output_labels: Sequence[str], /, use_torch: bool = False)[source]

Make a decorator for labeling the input/output columns of array-based callables.

Useful for creating parameter-to-target lookups from array-based logic. The decorator transforms a callable designed to work with unlabelled arrays such that it can operate with dataframes instead. The original callable is expected to accept and return two-dimensional arrays. When decorated, the callable accepts and returns dataframes whose columns are mapped to the corresponding arrays based on the specified label sequences.

Parameters:
  • input_labels (Sequence[str]) – The sequence of labels for the input columns.

  • output_labels (Sequence[str]) – The sequence of labels for the output columns.

  • use_torch (bool) – Flag indicating if the callable is to be called with a numpy array or with a torch tensor.

Return type:

Callable[[Callable[[TypeVar(_ArrayLike, ndarray, Tensor)], TypeVar(_ArrayLike, ndarray, Tensor)]], Callable[[DataFrame], DataFrame]]

Returns:

The decorator for the given input and output labels.