PyDP¶
Algorithms¶
-
class
pydp.algorithms.laplacian.BoundedMean(epsilon: float = 1.0, lower_bound: Optional[Union[int, float]] = None, upper_bound: Optional[Union[int, float]] = None, l0_sensitivity: int = 1, linf_sensitivity: int = 1, dtype: str = 'int')¶ BoundedMean computes the average of values in a dataset, in a differentially private manner.
Incrementally provides a differentially private average. All input vales are normalized to be their difference from the middle of the input range. That allows us to calculate the sum of all input values with half the sensitivity it would otherwise take for better accuracy (as compared to doing noisy sum / noisy count). This algorithm is taken from section 2.5.5 of the following book (algorithm 2.4): https://books.google.com/books?id=WFttDQAAQBAJ&pg=PA24#v=onepage&q&f=false
-
add_entries(data: List[Union[int, float]]) → None¶ Adds multiple inputs to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current list passed is not added.
-
add_entry(value: Union[int, float]) → None¶ Adds one input to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current data passed is not added.
-
property
epsilon¶ Returns the epsilon set at initialization.
-
property
l0_sensitivity¶ Returns the l0_sensitivity set at initialization.
-
property
linf_sensitivity¶ Returns the linf_sensitivity set at initialization.
-
merge(summary)¶ Merges serialized summary data into this algorithm. The summary proto must represent data from the same algorithm type with identical parameters. The data field must contain the algorithm summary type of the corresponding algorithm used. The summary proto cannot be empty.
-
noise_confidence_interval(confidence_level: float, privacy_budget: float) → float¶ Returns the confidence_level confidence interval of noise added within the algorithm with specified privacy budget, using epsilon and other relevant, algorithm-specific parameters (e.g. bounds) provided by the constructor.
This metric may be used to gauge the error rate introduced by the noise.
If the returned value is <x,y>, then the noise added has a confidence_level chance of being in the domain [x,y].
By default, NoiseConfidenceInterval() returns an error. Algorithms for which a confidence interval can feasibly be calculated override this and output the relevant value.
Conservatively, we do not release the error rate for algorithms whose confidence intervals rely on input size.
-
quick_result(data: List[Union[int, float]]) → Union[int, float]¶ Runs the algorithm on the input using the epsilon parameter provided in the constructor and returns output.
Consumes 100% of the privacy budget.
Note: It resets the privacy budget first.
-
reset() → None¶ Resets the algorithm to a state in which it has received no input. After Reset is called, the algorithm should only consider input added after the last Reset call when providing output.
-
result(privacy_budget: Optional[float] = None, noise_interval_level: Optional[float] = None) → Union[int, float]¶ Gets the algorithm result.
The default call consumes the remaining privacy budget.
When privacy_budget (defined on [0,1]) is set, it consumes only the privacy_budget amount of budget.
noise_interval_level provides the confidence level of the noise confidence interval, which may be included in the algorithm output.
-
serialize()¶ Serializes summary data of current entries into Summary proto. This allows results from distributed aggregation to be recorded and later merged.
Returns empty summary for algorithms for which serialize is unimplemented.
-
-
class
pydp.algorithms.laplacian.BoundedSum(epsilon: float = 1.0, lower_bound: Optional[Union[int, float]] = None, upper_bound: Optional[Union[int, float]] = None, l0_sensitivity: int = 1, linf_sensitivity: int = 1, dtype: str = 'int')¶ BoundedSum computes the sum of values in a dataset, in a differentially private manner.
Incrementally provides a differentially private sum, clamped between upper and lower values. Bounds can be manually set or privately inferred.
-
add_entries(data: List[Union[int, float]]) → None¶ Adds multiple inputs to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current list passed is not added.
-
add_entry(value: Union[int, float]) → None¶ Adds one input to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current data passed is not added.
-
property
epsilon¶ Returns the epsilon set at initialization.
-
property
l0_sensitivity¶ Returns the l0_sensitivity set at initialization.
-
property
linf_sensitivity¶ Returns the linf_sensitivity set at initialization.
-
merge(summary)¶ Merges serialized summary data into this algorithm. The summary proto must represent data from the same algorithm type with identical parameters. The data field must contain the algorithm summary type of the corresponding algorithm used. The summary proto cannot be empty.
-
noise_confidence_interval(confidence_level: float, privacy_budget: float) → float¶ Returns the confidence_level confidence interval of noise added within the algorithm with specified privacy budget, using epsilon and other relevant, algorithm-specific parameters (e.g. bounds) provided by the constructor.
This metric may be used to gauge the error rate introduced by the noise.
If the returned value is <x,y>, then the noise added has a confidence_level chance of being in the domain [x,y].
By default, NoiseConfidenceInterval() returns an error. Algorithms for which a confidence interval can feasibly be calculated override this and output the relevant value.
Conservatively, we do not release the error rate for algorithms whose confidence intervals rely on input size.
-
quick_result(data: List[Union[int, float]]) → Union[int, float]¶ Runs the algorithm on the input using the epsilon parameter provided in the constructor and returns output.
Consumes 100% of the privacy budget.
Note: It resets the privacy budget first.
-
reset() → None¶ Resets the algorithm to a state in which it has received no input. After Reset is called, the algorithm should only consider input added after the last Reset call when providing output.
-
result(privacy_budget: Optional[float] = None, noise_interval_level: Optional[float] = None) → Union[int, float]¶ Gets the algorithm result.
The default call consumes the remaining privacy budget.
When privacy_budget (defined on [0,1]) is set, it consumes only the privacy_budget amount of budget.
noise_interval_level provides the confidence level of the noise confidence interval, which may be included in the algorithm output.
-
serialize()¶ Serializes summary data of current entries into Summary proto. This allows results from distributed aggregation to be recorded and later merged.
Returns empty summary for algorithms for which serialize is unimplemented.
-
-
class
pydp.algorithms.laplacian.BoundedStandardDeviation(epsilon: float = 1.0, lower_bound: Optional[Union[int, float]] = None, upper_bound: Optional[Union[int, float]] = None, l0_sensitivity: int = 1, linf_sensitivity: int = 1, dtype: str = 'int')¶ BoundedStandardDeviation computes the standard deviation of values in a dataset, in a differentially private manner.
Incrementally provides a differentially private standard deviation for values in the range [lower..upper]. Values outside of this range will be clamped so they lie in the range. The output will also be clamped between 0 and (upper - lower).
The implementation simply computes the bounded variance and takes the square root, which is differentially private by the post-processing theorem. It relies on the fact that the bounded variance algorithm guarantees that the output is non-negative.
-
add_entries(data: List[Union[int, float]]) → None¶ Adds multiple inputs to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current list passed is not added.
-
add_entry(value: Union[int, float]) → None¶ Adds one input to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current data passed is not added.
-
property
epsilon¶ Returns the epsilon set at initialization.
-
property
l0_sensitivity¶ Returns the l0_sensitivity set at initialization.
-
property
linf_sensitivity¶ Returns the linf_sensitivity set at initialization.
-
merge(summary)¶ Merges serialized summary data into this algorithm. The summary proto must represent data from the same algorithm type with identical parameters. The data field must contain the algorithm summary type of the corresponding algorithm used. The summary proto cannot be empty.
-
noise_confidence_interval(confidence_level: float, privacy_budget: float) → float¶ Returns the confidence_level confidence interval of noise added within the algorithm with specified privacy budget, using epsilon and other relevant, algorithm-specific parameters (e.g. bounds) provided by the constructor.
This metric may be used to gauge the error rate introduced by the noise.
If the returned value is <x,y>, then the noise added has a confidence_level chance of being in the domain [x,y].
By default, NoiseConfidenceInterval() returns an error. Algorithms for which a confidence interval can feasibly be calculated override this and output the relevant value.
Conservatively, we do not release the error rate for algorithms whose confidence intervals rely on input size.
-
quick_result(data: List[Union[int, float]]) → Union[int, float]¶ Runs the algorithm on the input using the epsilon parameter provided in the constructor and returns output.
Consumes 100% of the privacy budget.
Note: It resets the privacy budget first.
-
reset() → None¶ Resets the algorithm to a state in which it has received no input. After Reset is called, the algorithm should only consider input added after the last Reset call when providing output.
-
result(privacy_budget: Optional[float] = None, noise_interval_level: Optional[float] = None) → Union[int, float]¶ Gets the algorithm result.
The default call consumes the remaining privacy budget.
When privacy_budget (defined on [0,1]) is set, it consumes only the privacy_budget amount of budget.
noise_interval_level provides the confidence level of the noise confidence interval, which may be included in the algorithm output.
-
serialize()¶ Serializes summary data of current entries into Summary proto. This allows results from distributed aggregation to be recorded and later merged.
Returns empty summary for algorithms for which serialize is unimplemented.
-
-
class
pydp.algorithms.laplacian.BoundedVariance(epsilon: float = 1.0, lower_bound: Optional[Union[int, float]] = None, upper_bound: Optional[Union[int, float]] = None, l0_sensitivity: int = 1, linf_sensitivity: int = 1, dtype: str = 'int')¶ BoundedVariance computes the variance of values in a dataset, in a differentially private manner.
Incrementally provides a differentially private variance for values in the range [lower..upper]. Values outside of this range will be clamped so they lie in the range. The output will also be clamped between 0 and (upper - lower)^2. Since the result is guaranteed to be positive, this algorithm can be used to compute a differentially private standard deviation.
The algorithm uses O(1) memory and runs in O(n) time where n is the size of the dataset, making it a fast and efficient. The amount of noise added grows quadratically in (upper - lower) and decreases linearly in n, so it might not produce good results unless n >> (upper - lower)^2.
The algorithm is a variation of the algorithm for differentially private mean from “Differential Privacy: From Theory to Practice”, section 2.5.5: https://books.google.com/books?id=WFttDQAAQBAJ&pg=PA24#v=onepage&q&f=false
-
add_entries(data: List[Union[int, float]]) → None¶ Adds multiple inputs to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current list passed is not added.
-
add_entry(value: Union[int, float]) → None¶ Adds one input to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current data passed is not added.
-
property
epsilon¶ Returns the epsilon set at initialization.
-
property
l0_sensitivity¶ Returns the l0_sensitivity set at initialization.
-
property
linf_sensitivity¶ Returns the linf_sensitivity set at initialization.
-
merge(summary)¶ Merges serialized summary data into this algorithm. The summary proto must represent data from the same algorithm type with identical parameters. The data field must contain the algorithm summary type of the corresponding algorithm used. The summary proto cannot be empty.
-
noise_confidence_interval(confidence_level: float, privacy_budget: float) → float¶ Returns the confidence_level confidence interval of noise added within the algorithm with specified privacy budget, using epsilon and other relevant, algorithm-specific parameters (e.g. bounds) provided by the constructor.
This metric may be used to gauge the error rate introduced by the noise.
If the returned value is <x,y>, then the noise added has a confidence_level chance of being in the domain [x,y].
By default, NoiseConfidenceInterval() returns an error. Algorithms for which a confidence interval can feasibly be calculated override this and output the relevant value.
Conservatively, we do not release the error rate for algorithms whose confidence intervals rely on input size.
-
quick_result(data: List[Union[int, float]]) → Union[int, float]¶ Runs the algorithm on the input using the epsilon parameter provided in the constructor and returns output.
Consumes 100% of the privacy budget.
Note: It resets the privacy budget first.
-
reset() → None¶ Resets the algorithm to a state in which it has received no input. After Reset is called, the algorithm should only consider input added after the last Reset call when providing output.
-
result(privacy_budget: Optional[float] = None, noise_interval_level: Optional[float] = None) → Union[int, float]¶ Gets the algorithm result.
The default call consumes the remaining privacy budget.
When privacy_budget (defined on [0,1]) is set, it consumes only the privacy_budget amount of budget.
noise_interval_level provides the confidence level of the noise confidence interval, which may be included in the algorithm output.
-
serialize()¶ Serializes summary data of current entries into Summary proto. This allows results from distributed aggregation to be recorded and later merged.
Returns empty summary for algorithms for which serialize is unimplemented.
-
-
class
pydp.algorithms.laplacian.Max(epsilon: float = 1.0, lower_bound: Optional[Union[int, float]] = None, upper_bound: Optional[Union[int, float]] = None, l0_sensitivity: int = 1, linf_sensitivity: int = 1, dtype: str = 'int')¶ Max computes the Max value in the dataset, in a differentially private manner.
-
add_entries(data: List[Union[int, float]]) → None¶ Adds multiple inputs to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current list passed is not added.
-
add_entry(value: Union[int, float]) → None¶ Adds one input to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current data passed is not added.
-
property
epsilon¶ Returns the epsilon set at initialization.
-
property
l0_sensitivity¶ Returns the l0_sensitivity set at initialization.
-
property
linf_sensitivity¶ Returns the linf_sensitivity set at initialization.
-
merge(summary)¶ Merges serialized summary data into this algorithm. The summary proto must represent data from the same algorithm type with identical parameters. The data field must contain the algorithm summary type of the corresponding algorithm used. The summary proto cannot be empty.
-
noise_confidence_interval(confidence_level: float, privacy_budget: float) → float¶ Returns the confidence_level confidence interval of noise added within the algorithm with specified privacy budget, using epsilon and other relevant, algorithm-specific parameters (e.g. bounds) provided by the constructor.
This metric may be used to gauge the error rate introduced by the noise.
If the returned value is <x,y>, then the noise added has a confidence_level chance of being in the domain [x,y].
By default, NoiseConfidenceInterval() returns an error. Algorithms for which a confidence interval can feasibly be calculated override this and output the relevant value.
Conservatively, we do not release the error rate for algorithms whose confidence intervals rely on input size.
-
quick_result(data: List[Union[int, float]]) → Union[int, float]¶ Runs the algorithm on the input using the epsilon parameter provided in the constructor and returns output.
Consumes 100% of the privacy budget.
Note: It resets the privacy budget first.
-
reset() → None¶ Resets the algorithm to a state in which it has received no input. After Reset is called, the algorithm should only consider input added after the last Reset call when providing output.
-
result(privacy_budget: Optional[float] = None, noise_interval_level: Optional[float] = None) → Union[int, float]¶ Gets the algorithm result.
The default call consumes the remaining privacy budget.
When privacy_budget (defined on [0,1]) is set, it consumes only the privacy_budget amount of budget.
noise_interval_level provides the confidence level of the noise confidence interval, which may be included in the algorithm output.
-
serialize()¶ Serializes summary data of current entries into Summary proto. This allows results from distributed aggregation to be recorded and later merged.
Returns empty summary for algorithms for which serialize is unimplemented.
-
-
class
pydp.algorithms.laplacian.Min(epsilon: float = 1.0, lower_bound: Optional[Union[int, float]] = None, upper_bound: Optional[Union[int, float]] = None, l0_sensitivity: int = 1, linf_sensitivity: int = 1, dtype: str = 'int')¶ Min computes the minium value in the dataset, in a differentially private manner.
-
add_entries(data: List[Union[int, float]]) → None¶ Adds multiple inputs to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current list passed is not added.
-
add_entry(value: Union[int, float]) → None¶ Adds one input to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current data passed is not added.
-
property
epsilon¶ Returns the epsilon set at initialization.
-
property
l0_sensitivity¶ Returns the l0_sensitivity set at initialization.
-
property
linf_sensitivity¶ Returns the linf_sensitivity set at initialization.
-
merge(summary)¶ Merges serialized summary data into this algorithm. The summary proto must represent data from the same algorithm type with identical parameters. The data field must contain the algorithm summary type of the corresponding algorithm used. The summary proto cannot be empty.
-
noise_confidence_interval(confidence_level: float, privacy_budget: float) → float¶ Returns the confidence_level confidence interval of noise added within the algorithm with specified privacy budget, using epsilon and other relevant, algorithm-specific parameters (e.g. bounds) provided by the constructor.
This metric may be used to gauge the error rate introduced by the noise.
If the returned value is <x,y>, then the noise added has a confidence_level chance of being in the domain [x,y].
By default, NoiseConfidenceInterval() returns an error. Algorithms for which a confidence interval can feasibly be calculated override this and output the relevant value.
Conservatively, we do not release the error rate for algorithms whose confidence intervals rely on input size.
-
quick_result(data: List[Union[int, float]]) → Union[int, float]¶ Runs the algorithm on the input using the epsilon parameter provided in the constructor and returns output.
Consumes 100% of the privacy budget.
Note: It resets the privacy budget first.
-
reset() → None¶ Resets the algorithm to a state in which it has received no input. After Reset is called, the algorithm should only consider input added after the last Reset call when providing output.
-
result(privacy_budget: Optional[float] = None, noise_interval_level: Optional[float] = None) → Union[int, float]¶ Gets the algorithm result.
The default call consumes the remaining privacy budget.
When privacy_budget (defined on [0,1]) is set, it consumes only the privacy_budget amount of budget.
noise_interval_level provides the confidence level of the noise confidence interval, which may be included in the algorithm output.
-
serialize()¶ Serializes summary data of current entries into Summary proto. This allows results from distributed aggregation to be recorded and later merged.
Returns empty summary for algorithms for which serialize is unimplemented.
-
-
class
pydp.algorithms.laplacian.Median(epsilon: float = 1.0, lower_bound: Optional[Union[int, float]] = None, upper_bound: Optional[Union[int, float]] = None, l0_sensitivity: int = 1, linf_sensitivity: int = 1, dtype: str = 'int')¶ Median computes the Median value in the dataset, in a differentially private manner.
-
add_entries(data: List[Union[int, float]]) → None¶ Adds multiple inputs to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current list passed is not added.
-
add_entry(value: Union[int, float]) → None¶ Adds one input to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current data passed is not added.
-
property
epsilon¶ Returns the epsilon set at initialization.
-
property
l0_sensitivity¶ Returns the l0_sensitivity set at initialization.
-
property
linf_sensitivity¶ Returns the linf_sensitivity set at initialization.
-
merge(summary)¶ Merges serialized summary data into this algorithm. The summary proto must represent data from the same algorithm type with identical parameters. The data field must contain the algorithm summary type of the corresponding algorithm used. The summary proto cannot be empty.
-
noise_confidence_interval(confidence_level: float, privacy_budget: float) → float¶ Returns the confidence_level confidence interval of noise added within the algorithm with specified privacy budget, using epsilon and other relevant, algorithm-specific parameters (e.g. bounds) provided by the constructor.
This metric may be used to gauge the error rate introduced by the noise.
If the returned value is <x,y>, then the noise added has a confidence_level chance of being in the domain [x,y].
By default, NoiseConfidenceInterval() returns an error. Algorithms for which a confidence interval can feasibly be calculated override this and output the relevant value.
Conservatively, we do not release the error rate for algorithms whose confidence intervals rely on input size.
-
quick_result(data: List[Union[int, float]]) → Union[int, float]¶ Runs the algorithm on the input using the epsilon parameter provided in the constructor and returns output.
Consumes 100% of the privacy budget.
Note: It resets the privacy budget first.
-
reset() → None¶ Resets the algorithm to a state in which it has received no input. After Reset is called, the algorithm should only consider input added after the last Reset call when providing output.
-
result(privacy_budget: Optional[float] = None, noise_interval_level: Optional[float] = None) → Union[int, float]¶ Gets the algorithm result.
The default call consumes the remaining privacy budget.
When privacy_budget (defined on [0,1]) is set, it consumes only the privacy_budget amount of budget.
noise_interval_level provides the confidence level of the noise confidence interval, which may be included in the algorithm output.
-
serialize()¶ Serializes summary data of current entries into Summary proto. This allows results from distributed aggregation to be recorded and later merged.
Returns empty summary for algorithms for which serialize is unimplemented.
-
-
class
pydp.algorithms.laplacian.Count(epsilon: float = 1.0, l0_sensitivity: int = 1, linf_sensitivity: int = 1, dtype: str = 'int')¶ Count computes the Count of number of items in the dataset, in a differentially private manner.
-
add_entries(data: List[Union[int, float]]) → None¶ Adds multiple inputs to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current list passed is not added.
-
add_entry(value: Union[int, float]) → None¶ Adds one input to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current data passed is not added.
-
property
epsilon¶ Returns the epsilon set at initialization.
-
property
l0_sensitivity¶ Returns the l0_sensitivity set at initialization.
-
property
linf_sensitivity¶ Returns the linf_sensitivity set at initialization.
-
merge(summary)¶ Merges serialized summary data into this algorithm. The summary proto must represent data from the same algorithm type with identical parameters. The data field must contain the algorithm summary type of the corresponding algorithm used. The summary proto cannot be empty.
-
noise_confidence_interval(confidence_level: float, privacy_budget: float) → float¶ Returns the confidence_level confidence interval of noise added within the algorithm with specified privacy budget, using epsilon and other relevant, algorithm-specific parameters (e.g. bounds) provided by the constructor.
This metric may be used to gauge the error rate introduced by the noise.
If the returned value is <x,y>, then the noise added has a confidence_level chance of being in the domain [x,y].
By default, NoiseConfidenceInterval() returns an error. Algorithms for which a confidence interval can feasibly be calculated override this and output the relevant value.
Conservatively, we do not release the error rate for algorithms whose confidence intervals rely on input size.
-
quick_result(data: List[Union[int, float]]) → Union[int, float]¶ Runs the algorithm on the input using the epsilon parameter provided in the constructor and returns output.
Consumes 100% of the privacy budget.
Note: It resets the privacy budget first.
-
reset() → None¶ Resets the algorithm to a state in which it has received no input. After Reset is called, the algorithm should only consider input added after the last Reset call when providing output.
-
result(privacy_budget: Optional[float] = None, noise_interval_level: Optional[float] = None) → Union[int, float]¶ Gets the algorithm result.
The default call consumes the remaining privacy budget.
When privacy_budget (defined on [0,1]) is set, it consumes only the privacy_budget amount of budget.
noise_interval_level provides the confidence level of the noise confidence interval, which may be included in the algorithm output.
-
serialize()¶ Serializes summary data of current entries into Summary proto. This allows results from distributed aggregation to be recorded and later merged.
Returns empty summary for algorithms for which serialize is unimplemented.
-
-
class
pydp.algorithms.laplacian.Percentile(epsilon: float = 1.0, percentile: float = 0.0, lower_bound: Optional[Union[int, float]] = None, upper_bound: Optional[Union[int, float]] = None, dtype: str = 'int')¶ Perencetile finds the value in the dataset with that percentile, in a differentially private manner.
-
add_entries(data: List[Union[int, float]]) → None¶ Adds multiple inputs to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current list passed is not added.
-
add_entry(value: Union[int, float]) → None¶ Adds one input to the algorithm.
Note: If the data exceeds the overflow limit of storage, the current data passed is not added.
-
property
epsilon¶ Returns the epsilon set at initialization.
-
property
l0_sensitivity¶ Returns the l0_sensitivity set at initialization.
-
property
linf_sensitivity¶ Returns the linf_sensitivity set at initialization.
-
merge(summary)¶ Merges serialized summary data into this algorithm. The summary proto must represent data from the same algorithm type with identical parameters. The data field must contain the algorithm summary type of the corresponding algorithm used. The summary proto cannot be empty.
-
noise_confidence_interval(confidence_level: float, privacy_budget: float) → float¶ Returns the confidence_level confidence interval of noise added within the algorithm with specified privacy budget, using epsilon and other relevant, algorithm-specific parameters (e.g. bounds) provided by the constructor.
This metric may be used to gauge the error rate introduced by the noise.
If the returned value is <x,y>, then the noise added has a confidence_level chance of being in the domain [x,y].
By default, NoiseConfidenceInterval() returns an error. Algorithms for which a confidence interval can feasibly be calculated override this and output the relevant value.
Conservatively, we do not release the error rate for algorithms whose confidence intervals rely on input size.
-
property
percentile¶ percentile Gets the value that was set in the constructor.
-
quick_result(data: List[Union[int, float]]) → Union[int, float]¶ Runs the algorithm on the input using the epsilon parameter provided in the constructor and returns output.
Consumes 100% of the privacy budget.
Note: It resets the privacy budget first.
-
reset() → None¶ Resets the algorithm to a state in which it has received no input. After Reset is called, the algorithm should only consider input added after the last Reset call when providing output.
-
result(privacy_budget: Optional[float] = None, noise_interval_level: Optional[float] = None) → Union[int, float]¶ Gets the algorithm result.
The default call consumes the remaining privacy budget.
When privacy_budget (defined on [0,1]) is set, it consumes only the privacy_budget amount of budget.
noise_interval_level provides the confidence level of the noise confidence interval, which may be included in the algorithm output.
-
serialize()¶ Serializes summary data of current entries into Summary proto. This allows results from distributed aggregation to be recorded and later merged.
Returns empty summary for algorithms for which serialize is unimplemented.
-
Distributions¶
-
class
pydp.distributions.GaussianDistribution¶ -
sample(self: pydp.GaussianDistribution, scale: float = 1.0) → float¶ - Samples the Gaussian with distribution Gauss(scale*stddev).
- scale
A factor to scale stddev.
-
property
stddev¶ Returns stddev
-
-
class
pydp.distributions.LaplaceDistribution¶ Draws samples from the Laplacian distribution.
-
get_diversity(self: pydp.LaplaceDistribution) → float¶ Returns the parameter defining this distribution, often labeled b.
-