Skip to content

Commit

Permalink
feat: don't answer the query if epsilon > 100
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasopaum committed Jun 13, 2023
1 parent e9c6a79 commit 59a4cbf
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/boundedCovarianceDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@


boundedCovarianceDP <- function(x, y, epsilon, x_min, x_max, y_min, y_max) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}
res <- py_module$custom_dp$covariance_custom$custom_bounded_covariance(x, y, epsilon, x_min, x_max, y_min, y_max)
return(res)
}
5 changes: 5 additions & 0 deletions R/boundedMeanDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


boundedMeanDP <- function(input_data, epsilon, lower_bound, upper_bound) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

mean <- py_module$pydp_wrapper$mean_PyDP$pyDP_bounded_mean(input_data, epsilon / 2, lower_bound, upper_bound)
length <- py_module$pydp_wrapper$count_PyDP$pyDP_count(input_data, epsilon / 2)

Expand Down
5 changes: 5 additions & 0 deletions R/boundedStandardDeviationDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


boundedStandardDeviationDP <- function(input_data, epsilon, lower_bound, upper_bound) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

res <- py_module$pydp_wrapper$standard_deviation_PyDP$pyDP_bounded_standard_deviation(input_data, epsilon, lower_bound, upper_bound)
return(res)
}
5 changes: 5 additions & 0 deletions R/boundedSumDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


boundedSumDP <- function(input_data, epsilon, lower_bound, upper_bound) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

res <- py_module$pydp_wrapper$sum_PyDP$pyDP_bounded_sum(input_data, epsilon, lower_bound, upper_bound)
return(res)
}
5 changes: 5 additions & 0 deletions R/boundedVarianceDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


boundedVarianceDP <- function(input_data, epsilon, lower_bound, upper_bound) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

res <- py_module$pydp_wrapper$variance_PyDP$pyDP_bounded_variance(input_data, epsilon, lower_bound, upper_bound)
return(res)
}
5 changes: 5 additions & 0 deletions R/countDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@


countDP <- function(input_data, epsilon) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

res <- py_module$pydp_wrapper$count_PyDP$pyDP_count(input_data, epsilon)
return(res)
}
5 changes: 5 additions & 0 deletions R/linearRegressionDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@


linearRegressionDP <- function(target_column, input_columns, epsilon) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

cbindtext <- paste0("cbind(", input_columns, ")")
input_X <- eval(parse(text=cbindtext), envir = parent.frame())

Expand Down
5 changes: 5 additions & 0 deletions R/maxDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


maxDP <- function(input_data, epsilon, lower_bound, upper_bound) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

res <- py_module$pydp_wrapper$max_PyDP$pyDP_max(input_data, epsilon, lower_bound, upper_bound)
return(res)
}
5 changes: 5 additions & 0 deletions R/medianDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


medianDP <- function(input_data, epsilon, lower_bound, upper_bound) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

median <- py_module$pydp_wrapper$median_PyDP$pyDP_median(input_data, epsilon / 2, lower_bound, upper_bound)
length <- py_module$pydp_wrapper$count_PyDP$pyDP_count(input_data, epsilon / 2)

Expand Down
5 changes: 5 additions & 0 deletions R/minDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


minDP <- function(input_data, epsilon, lower_bound, upper_bound) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

res <- py_module$pydp_wrapper$min_PyDP$pyDP_min(input_data, epsilon, lower_bound, upper_bound)
return(res)
}
5 changes: 5 additions & 0 deletions R/numValidDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@


numValidDP <- function(input_data, epsilon) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

length <- py_module$pydp_wrapper$count_PyDP$pyDP_count(input_data[!is.na(input_data)], epsilon)
return(length)
}
5 changes: 5 additions & 0 deletions R/sumDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


sumDP <- function(input_data, epsilon, lower_bound, upper_bound) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

sum <- py_module$pydp_wrapper$sum_PyDP$pyDP_bounded_sum(input_data, epsilon, lower_bound, upper_bound)
return(sum)
}
5 changes: 5 additions & 0 deletions R/sumOfSquaresDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


sumOfSquaresDP <- function(input_data, epsilon, lower_bound, upper_bound) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

lower_bound_square <- min(lower_bound^2, upper_bound^2)
upper_bound_square <- max(lower_bound^2, upper_bound^2)
sum_of_squares <- py_module$pydp_wrapper$sum_PyDP$pyDP_bounded_sum(input_data^2, epsilon, lower_bound_square, upper_bound_square)
Expand Down
5 changes: 5 additions & 0 deletions R/tableDP.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@


tableDP <- function(x, y, epsilon) {
# Don't answer the query if epsilon is too high
if(epsilon > 100){
stop("FAILED: espilon should be less than 100", call. = FALSE)
}

table <- DPpack::tableDP(x, y, eps = epsilon, which.sensitivity = "bounded", mechanism = "Laplace", type.DP = "pDP")
return(table)
}

0 comments on commit 59a4cbf

Please sign in to comment.