IBM/differential-privacy-library

using mechanisms individually

canoztas opened this issue · 2 comments

i have checked the documentation and could not find how to use mechanisms on a dataset without ML. is there such a feature? for instance, I just want to add gaussian mechanism to my dataset then check the rows.

You can use the mechanisms in isolation by initialising them and then using the randomise() method to randomise the input. If you want to run a mechanism on an input vector or array, you can use Numpy's vectorize function as follows:

import diffprivlib as dp
import numpy as np

mech = dp.mechanisms.Gaussian(epsilon=0.5, delta=1e-5, sensitivity=1)
vfunc = np.vectorize(mech.randomise)

and then run it on your array, vfunc(array).

thank you, besides that, how can i add data like noise to my original data ?