opendp.extras.sklearn.decomposition package#

Module contents#

This module requires extra installs: pip install opendp[scikit-learn]

For convenience, all the functions of this module are also available from opendp.prelude. We suggest importing under the conventional name dp:

>>> import opendp.prelude as dp

The methods of this module will then be accessible at dp.sklearn.decomposition.

See also our tutorial on diffentially private PCA.

class opendp.extras.sklearn.decomposition.PCAEpsilons(eigvals, eigvecs, mean)[source]#

Bases: NamedTuple

Parameters:
  • eigvals (float) –

  • eigvecs (list[float]) –

  • mean (float | None) –

eigvals: float#

Alias for field number 0

eigvecs: list[float]#

Alias for field number 1

mean: float | None#

Alias for field number 2

opendp.extras.sklearn.decomposition.make_private_pca(input_domain, input_metric, unit_epsilon, norm=None, num_components=None)[source]#

Construct a Measurement that returns the data mean, singular values and right singular vectors.

Parameters:
  • input_domain (Domain) – instance of array2_domain(size=_, num_columns=_)

  • input_metric (Metric) – instance of symmetric_distance()

  • unit_epsilon (float | PCAEpsilons) – ε-expenditure per changed record in the input data

  • norm (float | None) – clamp each row to this norm bound

  • num_components – optional, number of eigenvectors to release. defaults to num_columns from input_domain

Returns:

a Measurement that computes a tuple of (mean, S, Vt)

Return type:

Measurement