diff --git a/examples/1.1 - Introductions to PyDP.ipynb b/examples/1.1 - Introductions to PyDP.ipynb index b8b25135..133a1df5 100644 --- a/examples/1.1 - Introductions to PyDP.ipynb +++ b/examples/1.1 - Introductions to PyDP.ipynb @@ -1 +1,447 @@ -{"cells":[{"cell_type":"markdown","metadata":{"id":"pZgQLLVe1p47","colab_type":"text"},"source":["\n","## 1.1 Introduction to PyDP\n","The PyDP package provides a Python API into [Google's Differential Privacy library](https://github.com/google/differential-privacy). This example uses the alpha 0.1 version of the package that has the following limitations:\n","\n","\n","* Supports Linux (Windows coming soon)\n","* Supports Python 3.6 only (more support coming soon)\n","* Current implements an algorithm to support computing private mean using a Laplace noise generation technique.\n","* Supports only integer and floating point values\n","\n"]},{"cell_type":"code","metadata":{"id":"h67VRxjSSQ9b","colab_type":"code","outputId":"6da55f3e-cfb8-4503-a179-ec2613a7f8bd","executionInfo":{"status":"ok","timestamp":1587961311947,"user_tz":-600,"elapsed":8271,"user":{"displayName":"Ben Szymkow","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gj8JCwpOTvlaeImB7WktdTucJJTZ_kDAprKpf_sOA=s64","userId":"08454492702843508366"}},"colab":{"base_uri":"https://localhost:8080/","height":102}},"source":["# Install the PyDP package\n","! pip install python-dp"],"execution_count":1,"outputs":[{"output_type":"stream","text":["Collecting python-dp\n","\u001b[?25l Downloading https://files.pythonhosted.org/packages/dd/fb/7383d552f093c0cb0cc71a550eaa1c4bd504f3c62b267888c19ff0a8167d/python_dp-0.1.0-py2.py3-none-any.whl (3.6MB)\n","\r\u001b[K | | 10kB 18.6MB/s eta 0:00:01\r\u001b[K |▏ | 20kB 3.3MB/s eta 0:00:02\r\u001b[K |▎ | 30kB 4.7MB/s eta 0:00:01\r\u001b[K |▍ | 40kB 3.1MB/s eta 0:00:02\r\u001b[K |▌ | 51kB 3.8MB/s eta 0:00:01\r\u001b[K |▌ | 61kB 4.5MB/s eta 0:00:01\r\u001b[K |▋ | 71kB 5.2MB/s eta 0:00:01\r\u001b[K |▊ | 81kB 4.1MB/s eta 0:00:01\r\u001b[K |▉ | 92kB 4.5MB/s eta 0:00:01\r\u001b[K |█ | 102kB 5.0MB/s eta 0:00:01\r\u001b[K |█ | 112kB 5.0MB/s eta 0:00:01\r\u001b[K |█ | 122kB 5.0MB/s eta 0:00:01\r\u001b[K |█▏ | 133kB 5.0MB/s eta 0:00:01\r\u001b[K |█▎ | 143kB 5.0MB/s eta 0:00:01\r\u001b[K |█▍ | 153kB 5.0MB/s eta 0:00:01\r\u001b[K |█▌ | 163kB 5.0MB/s eta 0:00:01\r\u001b[K |█▋ | 174kB 5.0MB/s eta 0:00:01\r\u001b[K |█▋ | 184kB 5.0MB/s eta 0:00:01\r\u001b[K |█▊ | 194kB 5.0MB/s eta 0:00:01\r\u001b[K |█▉ | 204kB 5.0MB/s eta 0:00:01\r\u001b[K |██ | 215kB 5.0MB/s eta 0:00:01\r\u001b[K |██ | 225kB 5.0MB/s eta 0:00:01\r\u001b[K |██▏ | 235kB 5.0MB/s eta 0:00:01\r\u001b[K |██▏ | 245kB 5.0MB/s eta 0:00:01\r\u001b[K |██▎ | 256kB 5.0MB/s eta 0:00:01\r\u001b[K |██▍ | 266kB 5.0MB/s eta 0:00:01\r\u001b[K |██▌ | 276kB 5.0MB/s eta 0:00:01\r\u001b[K |██▋ | 286kB 5.0MB/s eta 0:00:01\r\u001b[K |██▊ | 296kB 5.0MB/s eta 0:00:01\r\u001b[K |██▊ | 307kB 5.0MB/s eta 0:00:01\r\u001b[K |██▉ | 317kB 5.0MB/s eta 0:00:01\r\u001b[K |███ | 327kB 5.0MB/s eta 0:00:01\r\u001b[K |███ | 337kB 5.0MB/s eta 0:00:01\r\u001b[K |███▏ | 348kB 5.0MB/s eta 0:00:01\r\u001b[K |███▏ | 358kB 5.0MB/s eta 0:00:01\r\u001b[K |███▎ | 368kB 5.0MB/s eta 0:00:01\r\u001b[K |███▍ | 378kB 5.0MB/s eta 0:00:01\r\u001b[K |███▌ | 389kB 5.0MB/s eta 0:00:01\r\u001b[K |███▋ | 399kB 5.0MB/s eta 0:00:01\r\u001b[K |███▊ | 409kB 5.0MB/s eta 0:00:01\r\u001b[K |███▊ | 419kB 5.0MB/s eta 0:00:01\r\u001b[K |███▉ | 430kB 5.0MB/s eta 0:00:01\r\u001b[K |████ | 440kB 5.0MB/s eta 0:00:01\r\u001b[K |████ | 450kB 5.0MB/s eta 0:00:01\r\u001b[K |████▏ | 460kB 5.0MB/s eta 0:00:01\r\u001b[K |████▎ | 471kB 5.0MB/s eta 0:00:01\r\u001b[K |████▎ | 481kB 5.0MB/s eta 0:00:01\r\u001b[K |████▍ | 491kB 5.0MB/s eta 0:00:01\r\u001b[K |████▌ | 501kB 5.0MB/s eta 0:00:01\r\u001b[K |████▋ | 512kB 5.0MB/s eta 0:00:01\r\u001b[K |████▊ | 522kB 5.0MB/s eta 0:00:01\r\u001b[K |████▉ | 532kB 5.0MB/s eta 0:00:01\r\u001b[K |████▉ | 542kB 5.0MB/s eta 0:00:01\r\u001b[K |█████ | 552kB 5.0MB/s eta 0:00:01\r\u001b[K |█████ | 563kB 5.0MB/s eta 0:00:01\r\u001b[K |█████▏ | 573kB 5.0MB/s eta 0:00:01\r\u001b[K |█████▎ | 583kB 5.0MB/s eta 0:00:01\r\u001b[K |█████▍ | 593kB 5.0MB/s eta 0:00:01\r\u001b[K |█████▍ | 604kB 5.0MB/s eta 0:00:01\r\u001b[K |█████▌ | 614kB 5.0MB/s eta 0:00:01\r\u001b[K |█████▋ | 624kB 5.0MB/s eta 0:00:01\r\u001b[K |█████▊ | 634kB 5.0MB/s eta 0:00:01\r\u001b[K |█████▉ | 645kB 5.0MB/s eta 0:00:01\r\u001b[K |█████▉ | 655kB 5.0MB/s eta 0:00:01\r\u001b[K |██████ | 665kB 5.0MB/s eta 0:00:01\r\u001b[K |██████ | 675kB 5.0MB/s eta 0:00:01\r\u001b[K |██████▏ | 686kB 5.0MB/s eta 0:00:01\r\u001b[K |██████▎ | 696kB 5.0MB/s eta 0:00:01\r\u001b[K |██████▍ | 706kB 5.0MB/s eta 0:00:01\r\u001b[K |██████▍ | 716kB 5.0MB/s eta 0:00:01\r\u001b[K |██████▌ | 727kB 5.0MB/s eta 0:00:01\r\u001b[K |██████▋ | 737kB 5.0MB/s eta 0:00:01\r\u001b[K |██████▊ | 747kB 5.0MB/s eta 0:00:01\r\u001b[K |██████▉ | 757kB 5.0MB/s eta 0:00:01\r\u001b[K |███████ | 768kB 5.0MB/s eta 0:00:01\r\u001b[K |███████ | 778kB 5.0MB/s eta 0:00:01\r\u001b[K |███████ | 788kB 5.0MB/s eta 0:00:01\r\u001b[K |███████▏ | 798kB 5.0MB/s eta 0:00:01\r\u001b[K |███████▎ | 808kB 5.0MB/s eta 0:00:01\r\u001b[K |███████▍ | 819kB 5.0MB/s eta 0:00:01\r\u001b[K |███████▌ | 829kB 5.0MB/s eta 0:00:01\r\u001b[K |███████▌ | 839kB 5.0MB/s eta 0:00:01\r\u001b[K |███████▋ | 849kB 5.0MB/s eta 0:00:01\r\u001b[K |███████▊ | 860kB 5.0MB/s eta 0:00:01\r\u001b[K |███████▉ | 870kB 5.0MB/s eta 0:00:01\r\u001b[K |████████ | 880kB 5.0MB/s eta 0:00:01\r\u001b[K |████████ | 890kB 5.0MB/s eta 0:00:01\r\u001b[K |████████ | 901kB 5.0MB/s eta 0:00:01\r\u001b[K |████████▏ | 911kB 5.0MB/s eta 0:00:01\r\u001b[K |████████▎ | 921kB 5.0MB/s eta 0:00:01\r\u001b[K |████████▍ | 931kB 5.0MB/s eta 0:00:01\r\u001b[K |████████▌ | 942kB 5.0MB/s eta 0:00:01\r\u001b[K |████████▌ | 952kB 5.0MB/s eta 0:00:01\r\u001b[K |████████▋ | 962kB 5.0MB/s eta 0:00:01\r\u001b[K |████████▊ | 972kB 5.0MB/s eta 0:00:01\r\u001b[K |████████▉ | 983kB 5.0MB/s eta 0:00:01\r\u001b[K |█████████ | 993kB 5.0MB/s eta 0:00:01\r\u001b[K |█████████ | 1.0MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████ | 1.0MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████▏ | 1.0MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████▎ | 1.0MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████▍ | 1.0MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████▌ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████▋ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████▋ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████▊ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████▉ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████▏ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████▏ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████▎ | 1.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████▍ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████▌ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████▋ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████▊ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████▊ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████▉ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████▏ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████▏ | 1.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████▎ | 1.3MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████▍ | 1.3MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████▌ | 1.3MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████▋ | 1.3MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████▊ | 1.3MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████▊ | 1.3MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████▉ | 1.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████ | 1.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████ | 1.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████▏ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████▎ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████▎ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████▍ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████▌ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████▋ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████▊ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████▉ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████▉ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████ | 1.4MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████▏ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████▎ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████▍ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████▍ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████▌ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████▋ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████▊ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████▉ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████▉ | 1.5MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████▏ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████▎ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████▍ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████▍ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████▌ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████▋ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████▊ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████▉ | 1.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████ | 1.7MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████ | 1.7MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████ | 1.7MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████▏ | 1.7MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████▎ | 1.7MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████▍ | 1.7MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████▌ | 1.7MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████▌ | 1.7MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████▋ | 1.7MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████▊ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████▉ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████▏ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████▎ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████▍ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████▌ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████▌ | 1.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████▋ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████▊ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████▉ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████▏ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████▎ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████▍ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████▌ | 1.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████▋ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████▋ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████▊ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████▉ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████▏ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████▏ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████▎ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████▍ | 2.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████▌ | 2.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████▋ | 2.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████▊ | 2.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████▊ | 2.1MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████▉ | 2.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████ | 2.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████ | 2.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████▏ | 2.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████▎ | 2.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████▎ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████▍ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████▌ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████▋ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████▊ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████▊ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████▉ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████▏ | 2.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████▎ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████▎ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████▍ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████▌ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████▋ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████▊ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████▉ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████▉ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████ | 2.3MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████▏ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████▎ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████▍ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████▍ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████▌ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████▋ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████▊ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████▉ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████ | 2.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████▏ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████▎ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████▍ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████▍ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████▌ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████▋ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████▊ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████▉ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████ | 2.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████ | 2.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████ | 2.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████▏ | 2.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████▎ | 2.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████▍ | 2.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████▌ | 2.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████▌ | 2.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████▋ | 2.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████▊ | 2.6MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████▉ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████▏ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████▎ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████▍ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████▌ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████▋ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████▋ | 2.7MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████▊ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████▉ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████▏ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████▎ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████▍ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████▌ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████▋ | 2.8MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████▋ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████▊ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████▉ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████▏ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████▏ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████▎ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████▍ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████▌ | 2.9MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████▋ | 3.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████▊ | 3.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████▊ | 3.0MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████▉ | 3.0MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████ | 3.0MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████ | 3.0MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████▏ | 3.0MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████▎ | 3.0MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████▎ | 3.0MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████▍ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████▌ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████▋ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████▊ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████▊ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████▉ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████▏ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████▎ | 3.1MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████▎ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████▍ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████▌ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████▋ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████▊ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████▉ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████▉ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▏ | 3.2MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▎ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▍ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▍ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▌ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▋ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▊ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▉ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████ | 3.3MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▏ | 3.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▎ | 3.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▍ | 3.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▍ | 3.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▌ | 3.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▋ | 3.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▊ | 3.4MB 5.0MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▉ | 3.4MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████ | 3.4MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████ | 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████ | 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▏| 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▎| 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▍| 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▌| 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▌| 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▋| 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▊| 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▉| 3.5MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████████| 3.6MB 5.0MB/s eta 0:00:01\r\u001b[K |████████████████████████████████| 3.6MB 5.0MB/s \n","\u001b[?25hInstalling collected packages: python-dp\n","Successfully installed python-dp-0.1.0\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"ipGLypbRTDSc","colab_type":"code","colab":{}},"source":["import pydp as dp # by convention our package is to be imported as dp (for Differential Privacy!)\n","import pandas as pd\n","import statistics # for calculating mean without applying differential privacy"],"execution_count":0,"outputs":[]},{"cell_type":"code","metadata":{"id":"jM3luaaKSQ9h","colab_type":"code","outputId":"de008de4-f261-47ef-de5a-d33d23792c9d","executionInfo":{"status":"ok","timestamp":1587961449410,"user_tz":-600,"elapsed":1171,"user":{"displayName":"Ben Szymkow","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gj8JCwpOTvlaeImB7WktdTucJJTZ_kDAprKpf_sOA=s64","userId":"08454492702843508366"}},"colab":{"base_uri":"https://localhost:8080/","height":204}},"source":["# get carrots data from our public github repo\n","url = 'https://raw.githubusercontent.com/OpenMined/PyDP/dev/examples/animals_and_carrots.csv'\n","df = pd.read_csv(url,sep=\",\", names=[\"animal\", \"carrots_eaten\"])\n","df.head()"],"execution_count":5,"outputs":[{"output_type":"execute_result","data":{"text/html":["
\n","\n","\n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n","
animalcarrots_eaten
0Aardvark1
1Albatross88
2Alligator35
3Alpaca99
4Ant69
\n","
"],"text/plain":[" animal carrots_eaten\n","0 Aardvark 1\n","1 Albatross 88\n","2 Alligator 35\n","3 Alpaca 99\n","4 Ant 69"]},"metadata":{"tags":[]},"execution_count":5}]},{"cell_type":"markdown","metadata":{},"source":["Taking Mean of all the entries in a normal fashion without Applying the DP library. This is the actual mean of all the records."]},{"cell_type":"code","metadata":{"id":"5_pUyyKzW1YC","colab_type":"code","colab":{}},"source":["# calculates mean without applying differential privacy\n","def mean_carrots() -> float:\n"," return statistics.mean(list(df[\"carrots_eaten\"]))"],"execution_count":0,"outputs":[]},{"cell_type":"markdown","metadata":{},"source":["Private Mean uses Differential Privacy Library by Google to calculate the Mean. To preserve privacy, Laplacian mechanism is used.\n","\n","The function takes the argument privacy_budget as input.\n","\n","It is a number between 0 and 1, denoting privacy threshold\n","\n","It measures the acceptable loss of privacy (with 0 meaning no loss is acceptable).\n","\n","`dp.BoundedMean.result()` takes a List of integer/ float as an input and returns the list \n"]},{"cell_type":"code","metadata":{"id":"0AMReuBXTaLV","colab_type":"code","colab":{}},"source":["# calculates mean applying differential privacy\n","def private_mean(privacy_budget: float) -> float:\n"," x = dp.BoundedMean(privacy_budget)\n"," return x.result(list(df[\"carrots_eaten\"]))"],"execution_count":0,"outputs":[]},{"cell_type":"markdown","metadata":{},"source":["As you can see, the value of Private Mean varries compares to the Mean calculted using normal Statistical methods.\n","\n","This difference in values refers to that privacy is actually preserved for individual records in it."]},{"cell_type":"code","metadata":{"id":"vgkt7BuZW3Vw","colab_type":"code","outputId":"f5708cb5-1477-4f05-851b-b40ae7d3125d","executionInfo":{"status":"ok","timestamp":1587961454996,"user_tz":-600,"elapsed":749,"user":{"displayName":"Ben Szymkow","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gj8JCwpOTvlaeImB7WktdTucJJTZ_kDAprKpf_sOA=s64","userId":"08454492702843508366"}},"colab":{"base_uri":"https://localhost:8080/","height":51}},"source":["print(\"Mean: \", mean_carrots())\n","print(\"Private Mean: \", private_mean(0.8))"],"execution_count":8,"outputs":[{"output_type":"stream","text":["Mean: 53.01648351648352\n","Private Mean: 71.27272727272728\n"],"name":"stdout"}]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.7.4"},"colab":{"name":"1.1 - Introductions to PyDP.ipynb","provenance":[{"file_id":"https://github.com/OpenMined/PyDP/blob/collab/examples/notebooks/001%20-%20Private%20Mean%20with%20Medical%20Data.ipynb","timestamp":1587868929244}],"collapsed_sections":[]}},"nbformat":4,"nbformat_minor":0} \ No newline at end of file +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "pZgQLLVe1p47" + }, + "source": [ + "\n", + "## 1.1 Introduction to PyDP\n", + "The PyDP package provides a Python API into [Google's Differential Privacy library](https://github.com/google/differential-privacy). This example uses the alpha 0.1 version of the package that has the following limitations:\n", + "\n", + "\n", + "* Supports Linux (Windows coming soon)\n", + "* Supports Python 3.6 only (more support coming soon)\n", + "* Current implements an algorithm to support computing private mean using a Laplace noise generation technique.\n", + "* Supports only integer and floating point values\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 102 + }, + "colab_type": "code", + "executionInfo": { + "elapsed": 8271, + "status": "ok", + "timestamp": 1587961311947, + "user": { + "displayName": "Ben Szymkow", + "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Gj8JCwpOTvlaeImB7WktdTucJJTZ_kDAprKpf_sOA=s64", + "userId": "08454492702843508366" + }, + "user_tz": -600 + }, + "id": "h67VRxjSSQ9b", + "outputId": "6da55f3e-cfb8-4503-a179-ec2613a7f8bd" + }, + "outputs": [], + "source": [ + "# Install the PyDP package\n", + "! pip install python-dp" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "ipGLypbRTDSc" + }, + "outputs": [], + "source": [ + "import pydp as dp # by convention our package is to be imported as dp (for Differential Privacy!)\n", + "import pandas as pd\n", + "import statistics # for calculating mean without applying differential privacy" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 204 + }, + "colab_type": "code", + "executionInfo": { + "elapsed": 1171, + "status": "ok", + "timestamp": 1587961449410, + "user": { + "displayName": "Ben Szymkow", + "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Gj8JCwpOTvlaeImB7WktdTucJJTZ_kDAprKpf_sOA=s64", + "userId": "08454492702843508366" + }, + "user_tz": -600 + }, + "id": "jM3luaaKSQ9h", + "outputId": "de008de4-f261-47ef-de5a-d33d23792c9d" + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
animalcarrots_eaten
0Aardvark1
1Albatross88
2Alligator35
3Alpaca99
4Ant69
\n", + "
" + ], + "text/plain": [ + " animal carrots_eaten\n", + "0 Aardvark 1\n", + "1 Albatross 88\n", + "2 Alligator 35\n", + "3 Alpaca 99\n", + "4 Ant 69" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# get carrots data from our public github repo\n", + "url = 'https://raw.githubusercontent.com/OpenMined/PyDP/dev/examples/animals_and_carrots.csv'\n", + "df = pd.read_csv(url,sep=\",\", names=[\"animal\", \"carrots_eaten\"])\n", + "df.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Taking Mean of all the entries in a normal fashion without Applying the DP library. This is the actual mean of all the records." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "5_pUyyKzW1YC" + }, + "outputs": [], + "source": [ + "# calculates mean without applying differential privacy\n", + "def mean_carrots() -> float:\n", + " return statistics.mean(list(df[\"carrots_eaten\"]))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Private Mean uses Differential Privacy Library by Google to calculate the Mean. To preserve privacy, Laplacian mechanism is used.\n", + "\n", + "The function takes the argument privacy_budget as input.\n", + "\n", + "It is a number between 0 and 1, denoting privacy threshold\n", + "\n", + "It measures the acceptable loss of privacy (with 0 meaning no loss is acceptable).\n", + "\n", + "`dp.BoundedMean.result()` takes a List of integer/ float as an input and returns the list \n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "0AMReuBXTaLV" + }, + "outputs": [], + "source": [ + "# calculates mean applying differential privacy\n", + "def private_mean(privacy_budget: float) -> float:\n", + " x = dp.BoundedMean(privacy_budget)\n", + " return x.result(list(df[\"carrots_eaten\"]))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As you can see, the value of Private Mean varries compares to the Mean calculted using normal Statistical methods.\n", + "\n", + "This difference in values refers to that privacy is actually preserved for individual records in it." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 51 + }, + "colab_type": "code", + "executionInfo": { + "elapsed": 749, + "status": "ok", + "timestamp": 1587961454996, + "user": { + "displayName": "Ben Szymkow", + "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14Gj8JCwpOTvlaeImB7WktdTucJJTZ_kDAprKpf_sOA=s64", + "userId": "08454492702843508366" + }, + "user_tz": -600 + }, + "id": "vgkt7BuZW3Vw", + "outputId": "f5708cb5-1477-4f05-851b-b40ae7d3125d" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Mean: 53.01648351648352\n", + "Private Mean: 72.34782608695653\n" + ] + } + ], + "source": [ + "print(\"Mean: \", mean_carrots())\n", + "print(\"Private Mean: \", private_mean(0.8))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Counts number of animals who ate more than 'limit' carrots without Applying the DP library. This is the actual number of such animals." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "# Calculates number of animals who ate more than \"limit\" carrots without applying differential privacy.\n", + "def count_above(limit: int) -> int:\n", + " return df[df.carrots_eaten > limit].count()[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Private Count Above uses Differential Privacy Library by Google to calculate the number of rows with value above limit. To preserve privacy, Laplacian mechanism is used.\n", + "\n", + "The function takes the argument privacy_budget as input.\n", + "\n", + "It is a number between 0 and 1, denoting privacy threshold\n", + "\n", + "It measures the acceptable loss of privacy (with 0 meaning no loss is acceptable).\n", + "\n", + "The function also takes the limit as an argument.\n", + "\n", + "`dp.CountInt.result()` takes a List of integer/ float as an input and returns the list " + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "# Calculates number of animals who ate more than \"limit\" carrots applying differential privacy.\n", + "def private_count_above(privacy_budget: float, limit: int) -> int:\n", + " x = dp.CountInt(privacy_budget)\n", + " return x.result(list(df[df.carrots_eaten > limit][\"carrots_eaten\"]))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As you can see, the value of Private Count Above varries compares to the Count calculted using normal Statistical methods.\n", + "\n", + "This difference in values refers to that privacy is actually preserved for individual records in it." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Above 70:\t65\n", + "private count above:\t64\n" + ] + } + ], + "source": [ + "print(\"Above 70:\\t\" + str(count_above(70)))\n", + "print(\"private count above:\\t\" + str(private_count_above(1, 70)))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Taking Max of all the entries in a normal fashion without Applying the DP library. This is the actual maximum of carrots eaten of all the records." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "# Function to return the maximum of the number of carrots eaten by any one animal without appyling differential privacy.\n", + "def max() -> int:\n", + " return df.max()[1]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Private Max uses Differential Privacy Library by Google to calculate the maximum out of all the values. To preserve privacy, Laplacian mechanism is used.\n", + "\n", + "The function takes the argument privacy_budget as input.\n", + "\n", + "It is a number between 0 and 1, denoting privacy threshold\n", + "\n", + "It measures the acceptable loss of privacy (with 0 meaning no loss is acceptable).\n", + "\n", + "`dp.Max.result()` takes a List of integer/ float as an input and returns the list." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "# Function to return the maximum of the number of carrots eaten by any one animal appyling differential privacy.\n", + "def private_max(privacy_budget: float) -> int:\n", + " # 0 and 150 are the upper and lower limits for the search bound.\n", + " x = dp.Max(privacy_budget, 0, 150)\n", + " return x.result(list(df[\"carrots_eaten\"]), privacy_budget)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As you can see, the value of Private Max varries compares to the Max calculted using normal Statistical methods.\n", + "\n", + "This difference in values refers to that privacy is actually preserved for individual records in it." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Max:\t100\n", + "private max:\t68.0\n" + ] + } + ], + "source": [ + "print(\"Max:\\t\" + str(max()))\n", + "print(\"private max:\\t\" + str(private_max(1)))" + ] + } + ], + "metadata": { + "colab": { + "collapsed_sections": [], + "name": "1.1 - Introductions to PyDP.ipynb", + "provenance": [ + { + "file_id": "https://github.com/OpenMined/PyDP/blob/collab/examples/notebooks/001%20-%20Private%20Mean%20with%20Medical%20Data.ipynb", + "timestamp": 1587868929244 + } + ] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.10" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +}