baybe.utils.dataframe.fuzzy_row_match

baybe.utils.dataframe.fuzzy_row_match(left_df: DataFrame, right_df: DataFrame, parameters: Sequence[Parameter])[source]

Match rows of the right dataframe to rows of the left dataframe.

This is useful for matching measurements to entries in the search space, e.g. to detect which ones have been measured. For categorical parameters, there needs to be an exact match with any of the allowed values. For numerical parameters, the points with the smallest deviation are considered.

Note

This function assumes that the dataframes contain only allowed values as specified in the parameter objects. No further validation to assert this is done.

Parameters:
  • left_df (DataFrame) – The data that serves as lookup reference.

  • right_df (DataFrame) – The data that is checked for matching rows in the left dataframe.

  • parameters (Sequence[Parameter]) – Parameter objects that identify the relevant column names and how matching is performed.

Return type:

Index

Returns:

The index of the matching rows in left_df.

Raises:

ValueError – If either left_df or right_df does not contain columns for each entry in parameters.