Validation functions¶
Validation functions for the differential privacy library
General functions¶

diffprivlib.validation.
check_epsilon_delta
(epsilon, delta, allow_zero=False)[source]¶ Checks that epsilon and delta are valid values for differential privacy. Throws an error if checks fail, otherwise returns nothing.
As well as the requirements of epsilon and delta separately, both cannot be simultaneously zero, unless
allow_zero
is set toTrue
.

diffprivlib.validation.
check_bounds
(bounds, shape=0, min_separation=0.0, dtype=<class 'float'>)[source]¶ Input validation for the
bounds
parameter.Checks that
bounds
is composed of a list of tuples of the form (lower, upper), where lower <= upper and both are numeric. Also checks thatbounds
contains the appropriate number of dimensions, and that there is amin_separation
between the bounds. Parameters
bounds (tuple) – Tuple of bounds of the form (min, max). min and max can either be scalars or 1dimensional arrays.
shape (int, default: 0) – Number of dimensions to be expected in
bounds
.min_separation (float, default: 0.0) – The minimum separation between lower and upper of each dimension. This separation is enforced if not already satisfied.
dtype (datatype, default: float) – Data type of the returned bounds.
 Returns
bounds
 Return type

diffprivlib.validation.
clip_to_norm
(array, clip)[source]¶ Clips the examples of a 2dimensional array to a given maximum norm.
 Parameters
array (np.ndarray) – Array to be clipped. After clipping, all examples have a 2norm of at most clip.
clip (float) – Norm at which to clip each example
 Returns
array – The clipped array.
 Return type
np.ndarray

diffprivlib.validation.
clip_to_bounds
(array, bounds)[source]¶ Clips the examples of a 2dimensional array to given bounds.
 Parameters
array (np.ndarray) – Array to be clipped. After clipping, all examples have a 2norm of at most clip.
bounds (tuple) – Tuple of bounds of the form (min, max) which the array is to be clipped to. min and max must be scalar, unless array is 2dimensional.
 Returns
array – The clipped array.
 Return type
np.ndarray