Clarification needed: Is this library to be used strictly on list of elements?
Closed this issue · 2 comments
Hello writers and maintainers:
The documentation pointing to dp.tools
has functions that act on some kind of aggregation of array
or array_like
"vectors". I wonder if there is a way to have the private outcome applied to individual elements of such a vector rather than some kind of aggregation like std
, sum
etc.
I am more than happy to contribute such a feature if you guide me whether it belongs here. My suggestion is on the lines of a utility function in tools/utils.py
def individual_application(array, epsilon=1.0, accountant=None, ...):
"""works on each individual numeric item in the `array`.
this could also take a dict instead of an `array`.
"""
# implemenation ...
Thank you,
Aman
Hi Aman,
You could apply a mechanism to every element of an array as follows:
def individual_application(array):
mech = Laplace(epsilon=1, sensitivity=1)
return [mech.randomise(val) for val in array]
In general, this is not recommended as it has an unfavourable privacy/accuracy tradeoff. It's not something we are considering adding to the library at present.