Title: | Easy Differential Privacy |
---|---|
Description: | An implementation of major general-purpose mechanisms for privatizing statistics, models, and machine learners, within the framework of differential privacy of Dwork et al. (2006) <doi:10.1007/11681878_14>. Example mechanisms include the Laplace mechanism for releasing numeric aggregates, and the exponential mechanism for releasing set elements. A sensitivity sampler (Rubinstein & Alda, 2017) <arXiv:1706.02562> permits sampling target non-private function sensitivity; combined with the generic mechanisms, it permits turn-key privatization of arbitrary programs. |
Authors: | Benjamin Rubinstein [aut, cre], Francesco Aldà [aut] |
Maintainer: | Benjamin Rubinstein <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.2.9000 |
Built: | 2024-11-20 04:05:34 UTC |
Source: | https://github.com/brubinstein/diffpriv |
Fits the basis of Bernstein polynomial functions to given real-valued
function f
of where
dims
, against
a regular lattice of points in each dimension for given
k
. Note the approximation is not the iterated variant.
bernstein(f, dims, k = 10)
bernstein(f, dims, k = 10)
f |
a function to be approximated. |
dims |
the function |
k |
the lattice resolution of approximation. |
an S3 object of class bernstein
.
Francesco Aldà and Benjamin I. P. Rubinstein. "The Bernstein Mechanism: Function Release under Differential Privacy", in Proceedings of the 31st AAAI Conference on Artificial Intelligence (AAAI'2017), pp. 1705-1711, Feb 2017.
predict.bernstein
for subsequent evaluation.
f <- function(x) x * sin(x*10) b <- bernstein(f, dims = 1) xs <- seq(from=0, to=1, length=50) mean((f(xs) - predict(b,xs))^2)
f <- function(x) x * sin(x*10) b <- bernstein(f, dims = 1) xs <- seq(from=0, to=1, length=50) mean((f(xs) - predict(b,xs))^2)
diffpriv
: practical differential privacy in R.The diffpriv
package is a collection of generic tools for privacy-aware
data science, under the formal framework of differential privacy. A
differentially-private mechanism can release responses to untrusted third
parties, models fit on privacy-sensitive data. Due to the formal worst-case
nature of the framework, however, mechanism development typically requires
theoretical analysis. diffpriv
offers a turn-key approach to
differential privacy.
Differential privacy's popularity is owed in part to a number of generic
mechanisms for privatizing non-private target functions. Virtual S4
class DPMech-class
captures common features of these mechanisms and
is superclass to:
DPMechLaplace
: the Laplace mechanism of Dwork et al.
(2006) for releasing numeric vectors;
DPMechExponential
: the exponential mechanism of McSherry
and Talwar (2007) for releasing solutions to optimizations, over numeric or
non-numeric sets; and
More mechanisms coming soon. Users can also develop new mechanisms by
subclassing DPMech-class
.
DPMech-class
-derived objects are initialized with a problem-specific
non-private target
function. Subsequently, the
releaseResponse
method can privatize responses of target
on input datasets. The level of corresponding privatization depends on given
privacy parameters DPParamsEps
or derived parameters object.
diffpriv
mechanisms have in common a reliance on the 'sensitivity' of
target
function to small changes to input datasets. This sensitivity
must be provably bounded for an application's target
in order for
differential privacy to be proved, and is used to calibrate privacy-preserving
randomization. Unfortunately bounding sensitivity is often prohibitively
complex, for example if target
is an arbitrary computer program. All
DPMech-class
mechanisms offer a sensitivitySampler
method due to Rubinstein and Aldà (2017) that repeatedly probes target
to estimate sensitivity automatically. Mechanisms with estimated sensitivities
achieve a slightly weaker form of random differential privacy due to
Hall et al. (2013), but without any theoretical analysis necessary.
Benjamin I. P. Rubinstein and Francesco Aldà. "Pain-Free Random Differential Privacy with Sensitivity Sampling", accepted into the 34th International Conference on Machine Learning (ICML'2017), May 2017.
Cynthia Dwork, Frank McSherry, Kobbi Nissim, and Adam Smith. "Calibrating noise to sensitivity in private data analysis." In Theory of Cryptography Conference, pp. 265-284. Springer Berlin Heidelberg, 2006.
Frank McSherry and Kunal Talwar. "Mechanism design via differential privacy." In the 48th Annual IEEE Symposium on Foundations of Computer Science (FOCS'07), pp. 94-103. IEEE, 2007.
Rob Hall, Alessandro Rinaldo, and Larry Wasserman. "Random Differential Privacy." Journal of Privacy and Confidentiality, 4(2), pp. 43-59, 2012.
## Not run: ## for full examples see the diffpriv vignette vignette("diffpriv") ## End(Not run)
## Not run: ## for full examples see the diffpriv vignette vignette("diffpriv") ## End(Not run)
A base class for representing output-perturbing mechanisms in differential
privacy. As this class is VIRTUAL
it cannot be instantiated, but it can
be subclassed.
sensitivity
non-negative scalar numeric target sensitivity. Defaults
to Inf
for use with sensitivitySampler()
.
target
the target non-private function to be privatized, takes lists. Defaults to a constant function.
gammaSensitivity
NA_real_
if inactive, or scalar in [0,1)
indicating that responses must be RDP with specific confidence.
Cynthia Dwork, Frank McSherry, Kobbi Nissim, and Adam Smith. "Calibrating noise to sensitivity in private data analysis." In Theory of Cryptography Conference, pp. 265-284. Springer Berlin Heidelberg, 2006.
DPMechLaplace
subclass for the Laplace mechanism.
A class that implements the Bernstein mechanism (not iterated version) of
differential privacy, for privatizing release of real-valued functions on
based on arbitrary datasets. Approximates the
target
on a lattice.
## S4 method for signature 'DPMechBernstein' show(object) ## S4 method for signature 'DPMechBernstein,DPParamsEps' releaseResponse(mechanism, privacyParams, X) ## S4 method for signature 'DPMechBernstein' sensitivityNorm(mechanism, X1, X2)
## S4 method for signature 'DPMechBernstein' show(object) ## S4 method for signature 'DPMechBernstein,DPParamsEps' releaseResponse(mechanism, privacyParams, X) ## S4 method for signature 'DPMechBernstein' sensitivityNorm(mechanism, X1, X2)
object |
an instance of class |
mechanism |
an object of class |
privacyParams |
an object of class |
X |
a privacy-sensitive dataset, if using sensitivity sampler a: list, matrix, data frame, numeric/character vector. |
X1 |
a privacy-sensitive dataset. |
X2 |
a privacy-sensitive dataset. |
list with slots per argument, actual privacy parameter and response:
mechanism response with length of target release:
privacyParams, sensitivity, latticeK, dims, target, response
.
scalar numeric norm of non-private target
on datasets.
The of the functions on a lattice.
show
: automatically prints the object.
releaseResponse
: releases Bernstein mechanism responses.
sensitivityNorm
: measures target
sensitivity.
sensitivity
non-negative scalar numeric maximum absolute target
sensitivity maximized over the lattice. Defaults to Inf
for use
with sensitivitySampler()
.
target
might be a closure that takes arbitrary dataset and returns a
real-valued function on .
gammaSensitivity
NA_real_
if inactive, or scalar in [0,1)
indicating that responses must be RDP with specific confidence.
latticeK
positive scalar integer-valued numeric specifying the lattice
resolution. Defaults to (invalid) NA_integer_
.
dims
positive scalar integer-valued numeric specifying the dimension
of released function domain. Defaults to (invalid) NA_integer_
.
Francesco Aldà and Benjamin I. P. Rubinstein. "The Bernstein Mechanism: Function Release under Differential Privacy", in Proceedings of the 31st AAAI Conference on Artificial Intelligence (AAAI'2017), pp. 1705-1711, Feb 2017.
## See the bernstein vignette
## See the bernstein vignette
A class that implements the exponential mechanism of differential privacy,
for privatizing releases from sets (not necessarily numeric as
required by DPMechLaplace
). Currently limited to responses
from a finite sets - the most widely used case - as these induce easily
computed sampling distributions from a uniform base measure.
## S4 method for signature 'DPMechExponential' show(object) ## S4 method for signature 'DPMechExponential,DPParamsEps' releaseResponse(mechanism, privacyParams, X) ## S4 method for signature 'DPMechExponential' sensitivityNorm(mechanism, X1, X2)
## S4 method for signature 'DPMechExponential' show(object) ## S4 method for signature 'DPMechExponential,DPParamsEps' releaseResponse(mechanism, privacyParams, X) ## S4 method for signature 'DPMechExponential' sensitivityNorm(mechanism, X1, X2)
object |
an instance of class |
mechanism |
an object of class |
privacyParams |
an object of class |
X |
a privacy-sensitive dataset, if using sensitivity sampler a: list, matrix, data frame, numeric/character vector. |
X1 |
a privacy-sensitive dataset. |
X2 |
a privacy-sensitive dataset. |
list with slots per argument, actual privacy parameter and response:
mechanism response with length of target release:
privacyParams, sensitivity, responseSet, target, response
.
scalar numeric norm of non-private target
on datasets.
show
: automatically prints the object.
releaseResponse
: releases exponential mechanism responses.
sensitivityNorm
: measures target
quality score sensitivity.
sensitivity
non-negative scalar numeric quality function sensitivity.
Defaults to Inf
for use with sensitivitySampler()
.
target
the quality score function mapping dataset to a function on
responses (elements of responseSet
).
gammaSensitivity
NA_real_
if inactive, or scalar in [0,1)
indicating that responses must be RDP with specific confidence.
responseSet
a list of possible responses of the mechanism.
Frank McSherry and Kunal Talwar. "Mechanism design via differential privacy." In the 48th Annual IEEE Symposium on Foundations of Computer Science (FOCS'07), pp. 94-103. IEEE, 2007.
## Sensitive data are strings of length at most 5. ## Task is to release most frequent character present, hence quality function ## is a closure that counts character frequencies for given candidate char. ## Global sensitivity is max string length. qualF <- function(X) { function(r) sum(r == unlist(strsplit(X, ""))) } rs <- as.list(letters) m <- DPMechExponential(sensitivity = 5, target = qualF, responseSet = rs) X <- strsplit("the quick brown fox jumps over the lazy dog"," ")[[1]] p <- DPParamsEps(epsilon = 1) releaseResponse(m, p, X)
## Sensitive data are strings of length at most 5. ## Task is to release most frequent character present, hence quality function ## is a closure that counts character frequencies for given candidate char. ## Global sensitivity is max string length. qualF <- function(X) { function(r) sum(r == unlist(strsplit(X, ""))) } rs <- as.list(letters) m <- DPMechExponential(sensitivity = 5, target = qualF, responseSet = rs) X <- strsplit("the quick brown fox jumps over the lazy dog"," ")[[1]] p <- DPParamsEps(epsilon = 1) releaseResponse(m, p, X)
A class that implements the Gaussian mechanism of differential privacy, for privatizing numeric vector releases.
## S4 method for signature 'DPMechGaussian' show(object)
## S4 method for signature 'DPMechGaussian' show(object)
object |
an instance of class |
show
: automatically prints the object.
sensitivity
non-negative scalar numeric L2 target sensitivity.
Defaults to Inf
for use with sensitivitySampler()
.
target
the target non-private function to be privatized, takes lists.
Defaults to a constant function. Gaussian mechanism assumes functions that
release numeric vectors of fixed dimension dims
.
gammaSensitivity
NA_real_
if inactive, or scalar in [0,1)
indicating that responses must be RDP with specific confidence.
dims
positive scalar numeric dimension of responses. Defaults to
NA_integer_
for use with sensitivitySampler()
which can
probe target
to determine dimension.
Cynthia Dwork and Aaron Roth. "Algorithmic Foundations of Differential Privacy" Foundations and Trends in Theoretical Computer Science. Now Publishers, 2014.
A class that implements the basic Laplace mechanism of differential privacy, for privatizing numeric vector releases.
## S4 method for signature 'DPMechLaplace' show(object)
## S4 method for signature 'DPMechLaplace' show(object)
object |
an instance of class |
show
: automatically prints the object.
sensitivity
non-negative scalar numeric L1 target sensitivity.
Defaults to Inf
for use with sensitivitySampler()
.
target
the target non-private function to be privatized, takes lists.
Defaults to a constant function. Laplace mechanism assumes functions that
release numeric vectors of fixed dimension dims
.
gammaSensitivity
NA_real_
if inactive, or scalar in [0,1)
indicating that responses must be RDP with specific confidence.
dims
positive scalar numeric dimension of responses. Defaults to
NA_integer_
for use with sensitivitySampler()
which can
probe target
to determine dimension.
Cynthia Dwork, Frank McSherry, Kobbi Nissim, and Adam Smith. "Calibrating noise to sensitivity in private data analysis." In Theory of Cryptography Conference, pp. 265-284. Springer Berlin Heidelberg, 2006.
A virtual class that implements common features of Laplace, Gaussian mechanisms from differential privacy, for privatizing numeric vector releases.
## S4 method for signature 'DPMechNumeric' show(object) ## S4 method for signature 'DPMechNumeric' sensitivityNorm(mechanism, X1, X2) ## S4 method for signature 'DPMechNumeric,DPParamsEps' releaseResponse(mechanism, privacyParams, X)
## S4 method for signature 'DPMechNumeric' show(object) ## S4 method for signature 'DPMechNumeric' sensitivityNorm(mechanism, X1, X2) ## S4 method for signature 'DPMechNumeric,DPParamsEps' releaseResponse(mechanism, privacyParams, X)
object |
an instance of class |
mechanism |
an object of class |
X1 |
a privacy-sensitive dataset. |
X2 |
a privacy-sensitive dataset. |
privacyParams |
an object of class |
X |
a privacy-sensitive dataset, if using sensitivity sampler a: list, matrix, data frame, numeric/character vector. |
scalar numeric norm of non-private target
on datasets.
list with slots per argument, actual privacy parameter;
mechanism response with length of target release:
privacyParams, sensitivity, dims, target, response
.
show
: automatically prints the object.
sensitivityNorm
: measures sensitivity of non-private target
.
releaseResponse
: releases mechanism responses.
sensitivity
non-negative scalar numeric target sensitivity.
Defaults to Inf
for use with sensitivitySampler()
.
target
the target non-private function to be privatized, takes lists.
Defaults to a constant function. Laplace mechanism assumes functions that
release numeric vectors of fixed dimension dims
.
gammaSensitivity
NA_real_
if deactive, or scalar in [0,1)
indicating that responses must be RDP with specific confidence.
dims
positive scalar numeric dimension of responses. Defaults to
NA_integer_
for use with sensitivitySampler()
which can
probe target
to determine dimension.
f <- function(xs) mean(xs) n <- 100 m <- DPMechLaplace(sensitivity = 1/n, target = f, dims = 1) X1 <- runif(n) X2 <- runif(n) sensitivityNorm(m, X1, X2) f <- function(xs) mean(xs) n <- 100 m <- DPMechLaplace(sensitivity = 1/n, target = f, dims = 1) X <- runif(n) p <- DPParamsEps(epsilon = 1) releaseResponse(m, p, X)
f <- function(xs) mean(xs) n <- 100 m <- DPMechLaplace(sensitivity = 1/n, target = f, dims = 1) X1 <- runif(n) X2 <- runif(n) sensitivityNorm(m, X1, X2) f <- function(xs) mean(xs) n <- 100 m <- DPMechLaplace(sensitivity = 1/n, target = f, dims = 1) X <- runif(n) p <- DPParamsEps(epsilon = 1) releaseResponse(m, p, X)
An S4 base class representing the privacy parameters in
-differential privacy.
## S4 method for signature 'DPParamsDel' show(object) ## S4 method for signature 'DPParamsDel' getDelta(object) ## S4 replacement method for signature 'DPParamsDel' setDelta(object) <- value ## S4 method for signature 'DPParamsDel,numeric' toGamma(object, gamma)
## S4 method for signature 'DPParamsDel' show(object) ## S4 method for signature 'DPParamsDel' getDelta(object) ## S4 replacement method for signature 'DPParamsDel' setDelta(object) <- value ## S4 method for signature 'DPParamsDel,numeric' toGamma(object, gamma)
object |
an object of class |
value |
a scalar numeric |
gamma |
a scalar numeric |
show
: automatically prints the object.
getDelta
: getter for slot delta
.
setDelta<-
: setter for slot delta
.
toGamma
: returns object to corresponding instance of subclass
DPParamsGam
.
epsilon
positive scalar numeric privacy level.
delta
a scalar numeric privacy level in interval [0,1).
DPParamsEps
superclass,
DPParamsGam
subclass for random relaxation.
An S4 base class representing the basic privacy parameter in
differential privacy.
## S4 method for signature 'DPParamsEps' show(object) ## S4 method for signature 'DPParamsEps' getEpsilon(object) ## S4 replacement method for signature 'DPParamsEps' setEpsilon(object) <- value ## S4 method for signature 'DPParamsEps,numeric' toGamma(object, gamma)
## S4 method for signature 'DPParamsEps' show(object) ## S4 method for signature 'DPParamsEps' getEpsilon(object) ## S4 replacement method for signature 'DPParamsEps' setEpsilon(object) <- value ## S4 method for signature 'DPParamsEps,numeric' toGamma(object, gamma)
object |
an object of class |
value |
a scalar numeric |
gamma |
a scalar numeric |
show
: automatically prints the object.
getEpsilon
: getter for slot epsilon
.
setEpsilon<-
: setter for slot epsilon
.
toGamma
: returns object to corresponding instance of subclass
DPParamsGam
.
epsilon
positive scalar numeric privacy level.
DPParamsDel
subclass for
relaxation,
DPParamsGam
subclass for random relaxation.
An S4 base class representing the privacy parameters in
-random differential privacy.
## S4 method for signature 'DPParamsGam' show(object) ## S4 method for signature 'DPParamsGam' getGamma(object) ## S4 replacement method for signature 'DPParamsGam' setGamma(object) <- value ## S4 method for signature 'DPParamsGam,numeric' toGamma(object, gamma)
## S4 method for signature 'DPParamsGam' show(object) ## S4 method for signature 'DPParamsGam' getGamma(object) ## S4 replacement method for signature 'DPParamsGam' setGamma(object) <- value ## S4 method for signature 'DPParamsGam,numeric' toGamma(object, gamma)
object |
an object of class |
value |
a scalar numeric |
gamma |
scalar numeric |
show
: automatically prints the object.
getGamma
: getter for slot gamma
.
setGamma<-
: setter for slot gamma
.
toGamma
: returns object with set gamma; generic for use with
superclasses DPParamsEps
and DPParamsDel
.
epsilon
positive scalar numeric privacy level.
delta
a scalar numeric privacy level in interval [0,1).
gamma
a scalar numeric privacy level in [0, 1).
DPParamsEps
, DPParamsDel
superclasses.
Evaluates a given S3 object of type bernstein
on given
data D
.
## S3 method for class 'bernstein' predict(object, D, ...)
## S3 method for class 'bernstein' predict(object, D, ...)
object |
an S3 object of type |
D |
either a numeric vector or matrix, all values in |
... |
additional arguments. |
a numeric vector of scalar real evaluations.
Francesco Aldà and Benjamin I. P. Rubinstein. "The Bernstein Mechanism: Function Release under Differential Privacy", in Proceedings of the 31st AAAI Conference on Artificial Intelligence (AAAI'2017), pp. 1705-1711, Feb 2017.
f <- function(x) x * sin(x*10) b <- bernstein(f, dims = 1) xs <- seq(from=0, to=1, length=50) mean((f(xs) - predict(b,xs))^2)
f <- function(x) x * sin(x*10) b <- bernstein(f, dims = 1) xs <- seq(from=0, to=1, length=50) mean((f(xs) - predict(b,xs))^2)
DPMech
private release method.Runs the differentially-private mechanism on given data.
releaseResponse(mechanism, privacyParams, X)
releaseResponse(mechanism, privacyParams, X)
mechanism |
an object of class |
privacyParams |
an object of class |
X |
a privacy-sensitive dataset, if using sensitivity sampler a: list, matrix, data frame, numeric/character vector. |
list with slots per argument, including at least: actual privacy
parameters privacyParams
, and response response
.
DPMech
sensitivity-inducing norm.Norm of a DPMech-class
's non-private target
function
evaluated on two given databases X1
, X2
.
sensitivityNorm(mechanism, X1, X2)
sensitivityNorm(mechanism, X1, X2)
mechanism |
an object of class |
X1 |
a privacy-sensitive dataset. |
X2 |
a privacy-sensitive dataset. |
DPMech-class
's.Given a constructed DPMech-class
, complete with target
function and sensitivityNorm,
and an oracle
for producing
records, samples the sensitivity of the target function to set the
mechanism's sensitivity
.
sensitivitySampler(object, oracle, n, m = NA_integer_, gamma = NA_real_)
sensitivitySampler(object, oracle, n, m = NA_integer_, gamma = NA_real_)
object |
an object of class |
oracle |
a source of random databases. A function returning: list,
matrix/data.frame (data in rows), numeric/character vector of records if
given desired length > 1; or single record given length 1, respectively
a list element, a row/named row, a single numeric/character. Whichever
type is used should be expected by |
n |
database size scalar positive numeric, integer-valued. |
m |
sensitivity sample size scalar positive numeric, integer-valued. |
gamma |
RDP privacy confidence level. |
object
with updated gammaSensitivity
slot.
Benjamin I. P. Rubinstein and Francesco Aldà. "Pain-Free Random Differential Privacy with Sensitivity Sampling", accepted into the 34th International Conference on Machine Learning (ICML'2017), May 2017.
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) m@sensitivity ## Inf m@gammaSensitivity ## NA as Laplace is naturally eps-DP P <- function(n) rnorm(n) m <- sensitivitySampler(m, oracle = P, n = 100, gamma = 0.33) m@sensitivity ## small like 0.03... m@gammaSensitivity ## 0.33 as directed, now m is (eps,gam)-DP.
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) m@sensitivity ## Inf m@gammaSensitivity ## NA as Laplace is naturally eps-DP P <- function(n) rnorm(n) m <- sensitivitySampler(m, oracle = P, n = 100, gamma = 0.33) m@sensitivity ## small like 0.03... m@gammaSensitivity ## 0.33 as directed, now m is (eps,gam)-DP.
DPMech-class
's.Given a constructed DPMech-class
, complete with target
function and sensitivityNorm,
and an oracle
for producing
records, samples the sensitivity of the target function to set the
mechanism's sensitivity
.
## S4 method for signature 'DPMech,'function',numeric' sensitivitySampler(object, oracle, n, m = NA_integer_, gamma = NA_real_)
## S4 method for signature 'DPMech,'function',numeric' sensitivitySampler(object, oracle, n, m = NA_integer_, gamma = NA_real_)
object |
an object of class |
oracle |
a source of random databases. A function returning: list,
matrix/data.frame (data in rows), numeric/character vector of records if
given desired length > 1; or single record given length 1, respectively
a list element, a row/named row, a single numeric/character. Whichever
type is used should be expected by |
n |
database size scalar positive numeric, integer-valued. |
m |
sensitivity sample size scalar positive numeric, integer-valued. |
gamma |
RDP privacy confidence level. |
object
with updated gammaSensitivity
slot.
Benjamin I. P. Rubinstein and Francesco Aldà. "Pain-Free Random Differential Privacy with Sensitivity Sampling", accepted into the 34th International Conference on Machine Learning (ICML'2017), May 2017.
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) m@sensitivity ## Inf m@gammaSensitivity ## NA as Laplace is naturally eps-DP P <- function(n) rnorm(n) m <- sensitivitySampler(m, oracle = P, n = 100, gamma = 0.33) m@sensitivity ## small like 0.03... m@gammaSensitivity ## 0.33 as directed, now m is (eps,gam)-DP.
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) m@sensitivity ## Inf m@gammaSensitivity ## NA as Laplace is naturally eps-DP P <- function(n) rnorm(n) m <- sensitivitySampler(m, oracle = P, n = 100, gamma = 0.33) m@sensitivity ## small like 0.03... m@gammaSensitivity ## 0.33 as directed, now m is (eps,gam)-DP.
DPMech-class
.Given a constructed DPMech-class
, complete with target
function and sensitivityNorm,
and an oracle
for producing
records, samples the sensitivity of the target function to set the
mechanism's sensitivity
. Typically the method
sensitivitySampler
should be used instead; NOTE this method
does not properly set the gammaSensitivity
slot of
DPMech-class
unlike the preferred method.
sensitivitySamplerManual(object, oracle, n, m, k)
sensitivitySamplerManual(object, oracle, n, m, k)
object |
an object of class |
oracle |
a source of random databases. A function returning: list,
matrix/data.frame (data in rows), numeric/character vector of records if
given desired length > 1; or single record given length 1, respectively
a list element, a row/named row, a single numeric/character. Whichever
type is used should be expected by |
n |
database size scalar positive numeric, integer-valued. |
m |
sensitivity sample size scalar positive numeric, integer-valued. |
k |
order statistic index in 1,..., |
object
with updated sensitivity parameter.
Benjamin I. P. Rubinstein and Francesco Aldà. "Pain-Free Random Differential Privacy with Sensitivity Sampling", accepted into the 34th International Conference on Machine Learning (ICML'2017), May 2017.
sensitivitySampler
preferred method for sensitivity
sampling.
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) P <- function(n) rnorm(n) m <- sensitivitySamplerManual(m, oracle = P, n = 100, m = 10, k = 10) m@sensitivity
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) P <- function(n) rnorm(n) m <- sensitivitySamplerManual(m, oracle = P, n = 100, m = 10, k = 10) m@sensitivity
DPMech-class
.Given a constructed DPMech-class
, complete with target
function and sensitivityNorm,
and an oracle
for producing
records, samples the sensitivity of the target function to set the
mechanism's sensitivity
. Typically the method
sensitivitySampler
should be used instead; NOTE this method
does not properly set the gammaSensitivity
slot of
DPMech-class
unlike the preferred method.
## S4 method for signature 'DPMech,'function',numeric,numeric,numeric' sensitivitySamplerManual(object, oracle, n, m, k)
## S4 method for signature 'DPMech,'function',numeric,numeric,numeric' sensitivitySamplerManual(object, oracle, n, m, k)
object |
an object of class |
oracle |
a source of random databases. A function returning: list,
matrix/data.frame (data in rows), numeric/character vector of records if
given desired length > 1; or single record given length 1, respectively
a list element, a row/named row, a single numeric/character. Whichever
type is used should be expected by |
n |
database size scalar positive numeric, integer-valued. |
m |
sensitivity sample size scalar positive numeric, integer-valued. |
k |
order statistic index in 1,..., |
object
with updated sensitivity parameter.
Benjamin I. P. Rubinstein and Francesco Aldà. "Pain-Free Random Differential Privacy with Sensitivity Sampling", accepted into the 34th International Conference on Machine Learning (ICML'2017), May 2017.
sensitivitySampler
preferred method for sensitivity
sampling.
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) P <- function(n) rnorm(n) m <- sensitivitySamplerManual(m, oracle = P, n = 100, m = 10, k = 10) m@sensitivity
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) P <- function(n) rnorm(n) m <- sensitivitySamplerManual(m, oracle = P, n = 100, m = 10, k = 10) m@sensitivity
DPMechNumeric-class
.Given a constructed DPMechNumeric-class
, complete with
target
function and sensitivityNorm,
and an oracle
for
producing records, samples the sensitivity of the target function to set the
mechanism's sensitivity
. Typically the method
sensitivitySampler
should be used instead; NOTE this method
does not properly set the gammaSensitivity
slot of
DPMech-class
unlike the preferred method. This method can
probe target
to determine response dimension when the
corresponding object@dims
is NA
.
## S4 method for signature 'DPMechNumeric,'function',numeric,numeric,numeric' sensitivitySamplerManual(object, oracle, n, m, k)
## S4 method for signature 'DPMechNumeric,'function',numeric,numeric,numeric' sensitivitySamplerManual(object, oracle, n, m, k)
object |
an object of class |
oracle |
a source of random databases. A function returning: list,
matrix/data.frame (data in rows), numeric/character vector of records if
given desired length > 1; or single record given length 1, respectively
a list element, a row/named row, a single numeric/character. Whichever
type is used should be expected by |
n |
database size scalar positive numeric, integer-valued. |
m |
sensitivity sample size scalar positive numeric, integer-valued. |
k |
order statistic index in 1,..., |
object
with updated sensitivity parameter, and (potentially)
dims
.
Benjamin I. P. Rubinstein and Francesco Aldà. "Pain-Free Random Differential Privacy with Sensitivity Sampling", accepted into the 34th International Conference on Machine Learning (ICML'2017), May 2017.
sensitivitySampler
preferred method for sensitivity
sampling.
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) P <- function(n) rnorm(n) m <- sensitivitySamplerManual(m, oracle = P, n = 100, m = 10, k = 10) m@sensitivity
## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) P <- function(n) rnorm(n) m <- sensitivitySamplerManual(m, oracle = P, n = 100, m = 10, k = 10) m@sensitivity
delta
.Use this method instead of slot delta
.
setDelta(object) <- value
setDelta(object) <- value
object |
the instance of |
value |
positive numeric |
epsilon
.Use this method instead of slot epsilon
.
setEpsilon(object) <- value
setEpsilon(object) <- value
object |
the instance of |
value |
positive numeric |
gamma
.Use this method instead of slot gamma
.
setGamma(object) <- value
setGamma(object) <- value
object |
the instance of |
value |
positive numeric |