secure_learning.utils.data_permutator module

Contains class used for data permutations

class secure_learning.utils.data_permutator.SecureDataPermutator(secure_permutations, seed=None)[source]

Bases: object

Class for performing data permutations.

Parameters:
  • secure_permutations (bool) – If True, perform permutations collaboratively using a secure permutation protocol. If False perform local permutations based on a shared random seed

  • seed (Optional[int]) – Set the random seed. A shared seed can be generated using the refresh_seed method

__init__(secure_permutations, seed=None)[source]

Constructor method.

insecure_data_permutation(matrix)[source]

Locally permute the rows of the provided matrix based on a shared random seed.

Parameters:

matrix (Sequence[Sequence[TypeVar(SecNumTypesTV, SecureFiniteField, SecureFixedPoint, SecureInteger)]]) – Matrix to be permuted

Raises:

SecureLearnValueError – Seed has not been set

Return type:

List[List[TypeVar(SecNumTypesTV, SecureFiniteField, SecureFixedPoint, SecureInteger)]]

Returns:

Matrix with shuffled rows

async refresh_seed()[source]

Generate common seed for future permutations.

Return type:

None

static secure_data_permutation(matrix)[source]

Permute the rows of the provided matrix using a secure permutation protocol.

Parameters:

matrix (Sequence[Sequence[TypeVar(SecNumTypesTV, SecureFiniteField, SecureFixedPoint, SecureInteger)]]) – Matrix to be permuted

Return type:

List[List[TypeVar(SecNumTypesTV, SecureFiniteField, SecureFixedPoint, SecureInteger)]]

Returns:

Matrix with shuffled rows

property seed: int

Seed used for randomness.

Raises:

SecureLearnValueError – Seed has not been set

Returns:

Seed used for randomness