Files
ml-sdk/docs/references/api/concrete.ml.pandas.dataframe.md
zeekay bde2e2531b Initial commit: Lux FHE ML SDK
Machine Learning with FHE - fork of Zama Concrete-ML
- Built-in FHE-friendly ML models
- scikit-learn compatible API
- PyTorch model conversion
- Quantization-aware training
2025-12-27 21:08:09 -08:00

7.4 KiB

module concrete.ml.pandas.dataframe

Define the encrypted data-frame framework.

Global Variables

  • ZIP_STORED

class EncryptedDataFrame

Define an encrypted data-frame framework that supports Pandas operators and parameters.

method __init__

__init__(
    encrypted_values: ndarray,
    encrypted_nan: Value,
    evaluation_keys: EvaluationKeys,
    column_names: List[str],
    dtype_mappings: Dict,
    api_version: int
)

property api_version

Get the API version used when instantiating this instance.

Returns:

  • int: The data-frame's API version.

property column_names

Get the data-frame's column names in order.

Returns:

  • List[str]: The data-frame's column names in order.

property column_names_to_position

Get the mapping between each column's name and its index position.

Returns:

  • Dict[str, int]: Mapping between column names and their position.

property dtype_mappings

Get the mappings for non-integer dtypes used in pre and post-processing.

Returns:

  • Dict: The mappings for non-integers dtypes.

property encrypted_nan

Get the encrypted value representing a NaN.

Returns:

  • fhe.Value: The encrypted representation of a NaN.

property encrypted_values

Get the encrypted values.

Returns:

  • numpy.ndarray: The array containing all encrypted values.

property evaluation_keys

Get the evaluation keys.

Returns:

  • fhe.EvaluationKeys: The evaluation keys.

method get_schema

get_schema() → DataFrame

Get the encrypted data-frame's scheme.

The scheme can include column names, dtypes or dtype mappings. It is displayed as a Pandas data-frame for better readability.

Returns:

  • pandas.DataFrame: The encrypted data-frame's scheme.

classmethod load

load(path: Union[Path, str])

Load an encrypted data-frame from disk.

Args:

  • path (Union[Path, str]): The path where to load the encrypted data-frame.

Returns:

  • EncryptedDataFrame: The loaded encrypted data-frame.

method merge

merge(
    other,
    how: str = 'left',
    on: Optional[str] = None,
    left_on: Optional[Hashable, Sequence[Hashable]] = None,
    right_on: Optional[Hashable, Sequence[Hashable]] = None,
    left_index: bool = False,
    right_index: bool = False,
    sort: bool = False,
    suffixes: Tuple[Optional[str], Optional[str]] = ('_x', '_y'),
    copy: Optional[bool] = None,
    indicator: Union[bool, str] = False,
    validate: Optional[str] = None
)

Merge two encrypted data-frames in FHE using Pandas parameters.

Note that for now, only a left and right join is implemented. Additionally, only some Pandas parameters are supported, and joining on multiple columns is not available.

Pandas documentation for version 2.0 can be found here: https://pandas.pydata.org/pandas-docs/version/2.0/reference/api/pandas.DataFrame.merge.html

Args:

  • other (EncryptedDataFrame): The other encrypted data-frame.
  • how (str): Type of merge to be performed, one of {'left', 'right'}.
  • * left: use only keys from left frame, similar to a SQL left outer join; preserve key order.
  • * right: use only keys from right frame, similar to a SQL right outer join; preserve key order.
  • on (Optional[str]): Column name to join on. These must be found in both DataFrames. If it is None then this defaults to the intersection of the columns in both DataFrames. Default to None.
  • left_on (Optional[Union[Hashable, Sequence[Hashable]]]): Currently not supported, please keep the default value. Default to None.
  • right_on (Optional[Union[Hashable, Sequence[Hashable]]]): Currently not supported, please keep the default value. Default to None.
  • left_index (bool): Currently not supported, please keep the default value. Default to False.
  • right_index (bool): Currently not supported, please keep the default value. Default to False.
  • sort (bool): Currently not supported, please keep the default value. Default to False.
  • suffixes (Tuple[Optional[str], Optional[str]]): A length-2 sequence where each element is optionally a string indicating the suffix to add to overlapping column names in left and right respectively. Pass a value of None instead of a string to indicate that the column name from left or right should be left as-is, with no suffix. At least one of the values must not be None.. Default to ("_x", "_y").
  • copy (Optional[bool]): Currently not supported, please keep the default value. Default to None.
  • indicator (Union[bool, str]): Currently not supported, please keep the default value. Default to False.
  • validate (Optional[str]): Currently not supported, please keep the default value. Default to None.

Returns:

  • EncryptedDataFrame: The joined encrypted data-frame.

method save

save(path: Union[Path, str])

Save the encrypted data-frame on disk.

Args:

  • path (Union[Path, str]): The path where to save the encrypted data-frame.