Skip to content

Repository files navigation

differential-privacy-clj

codecov

A Clojure wrapper for the Java differential-privacy library.

See online demo notebooks.

Installation

Steps to build it locally:

  1. Make sure you have Maven, Bazel and Leiningen installed.

  2. Download and build the Java differential-privacy library:

git clone https://github.com/google/differential-privacy.git
cd differential-privacy/java/
bazel build "..."
  1. Install libdifferentialprivacy.jar and libsummary-proto-speed.jar in your local Maven repository:
mvn install:install-file -Dfile=bazel-bin/main/com/google/privacy/differentialprivacy/libdifferentialprivacy.jar -DgroupId=com.google.privacy.differentialprivacy -DartifactId=libdifferentialprivacy -Dversion=1.0 -Dpackaging=jar
mvn install:install-file -Dfile=bazel-bin/external/com_google_differential_privacy/proto/libsummary-proto-speed.jar -DgroupId=com.google.differentialprivacy -DartifactId=libsummary-proto-speed -Dversion=1.0 -Dpackaging=jar
  1. Clone this repository and install the library:
git clone https://github.com/OpenMined/clojure-dp.git
cd clojure-dp
lein install

Usage

See demo notebooks (run online).

Examples:

(require '[differential-privacy-clj.core :as dp])
(defexample-data (take1000 (repeatedly #(rand10.0))))
(println"True sum: "
(reduce + example-data))
(println"DP sum: "
(dp/bounded-sum example-data :epsilon0.1:lower0:upper10:max-partitions-contributed1))
(println"True count:"
(count example-data))
(println"DP count: "
(dp/count example-data :epsilon0.1:max-partitions-contributed1))
(println"True mean:" (/ (reduce + example-data)
(count example-data)))
(println"DP mean:" (dp/bounded-mean example-data :epsilon0.1:lower0:upper10:max-partitions-contributed1:max-contributions-per-partition1))

will print something like:

True sum: 4988.542973798648
DP sum: 5175.075793958153
True count: 1000
DP count: 999
True mean: 4.988542973798648
DP mean: 5.002603661455349

Available algorithms:

✔️ - Supported ✅ - Planned

Algorithm
Count✔️
Sum✔️
Mean✔️
Variance
Standard deviation
Order statistics (incl. min, max, and median)

Support

For support in using this library, please join the #lib_dp_java Slack channel. If you’d like to follow along with any code changes to the library, please join the #code_dp_clojure Slack channel. Click here to join our Slack community!

About

No description or website provided.

Topics

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

9 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages