Skip to content

Commit f5c5637

Browse files
authored
[MNT] Diffprivlib 0.6 (#74)
* Updating dependency tests and removing support for Python 3.7 * Updating readthedocs.yml * Updating notebooks * Adding CodeQL scanning to GH Actions * Updating README versions and badges * Updating version number
1 parent aa41f7c commit f5c5637

17 files changed

+226
-129
lines changed

.github/workflows/codeql.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: ['**']
17+
pull_request:
18+
branches: [ main ]
19+
20+
jobs:
21+
analyze:
22+
name: Analyze
23+
runs-on: ubuntu-latest
24+
permissions:
25+
actions: read
26+
contents: read
27+
security-events: write
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
language: [ 'python' ]
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v3
37+
38+
# Initializes the CodeQL tools for scanning.
39+
- name: Initialize CodeQL
40+
uses: github/codeql-action/init@v2
41+
with:
42+
languages: ${{ matrix.language }}
43+
44+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
45+
# If this step fails, then you should remove it and run the build manually (see below)
46+
- name: Autobuild
47+
uses: github/codeql-action/autobuild@v2
48+
49+
- name: Perform CodeQL Analysis
50+
uses: github/codeql-action/analyze@v2
51+
with:
52+
category: "/language:${{matrix.language}}"

.github/workflows/general.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: ['3.7', '3.8', '3.9', '3.10']
20+
python-version: ['3.8', '3.9', '3.10']
2121

2222
steps:
2323
- uses: actions/checkout@v2

.github/workflows/libraries.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,26 @@ jobs:
1919

2020
matrix:
2121
include:
22-
- library: numpy
23-
version: 1.19.5
24-
python-version: 3.8
25-
- library: numpy
26-
version: 1.20.3
27-
python-version: 3.9
2822
- library: numpy
2923
version: 1.21.6
30-
python-version: 3.9
24+
python-version: '3.10'
25+
- library: numpy
26+
version: 1.22.4
27+
python-version: '3.10'
3128

32-
- library: scikit-learn
33-
version: 0.23.2
34-
python-version: 3.8
3529
- library: scikit-learn
3630
version: 0.24.2
3731
python-version: 3.9
3832
- library: scikit-learn
3933
version: 1.0.2
40-
python-version: 3.9
34+
python-version: '3.10'
4135

42-
- library: scipy
43-
version: 1.5.4
44-
python-version: 3.8
45-
- library: scipy
46-
version: 1.6.3
47-
python-version: 3.8
4836
- library: scipy
4937
version: 1.7.3
50-
python-version: 3.9
38+
python-version: '3.10'
39+
- library: scipy
40+
version: 1.8.1
41+
python-version: '3.10'
5142

5243
- library: crlibm
5344
python-version: '3.10'

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Diffprivlib v0.5
1+
# Diffprivlib v0.6
22

33
[![Python versions](https://img.shields.io/pypi/pyversions/diffprivlib.svg)](https://pypi.org/project/diffprivlib/)
44
[![Downloads](https://pepy.tech/badge/diffprivlib)](https://pepy.tech/project/diffprivlib)
55
[![PyPi version](https://img.shields.io/pypi/v/diffprivlib.svg)](https://pypi.org/project/diffprivlib/)
66
[![PyPi status](https://img.shields.io/pypi/status/diffprivlib.svg)](https://pypi.org/project/diffprivlib/)
77
[![General tests](https://github.com/IBM/differential-privacy-library/actions/workflows/general.yml/badge.svg)](https://github.com/IBM/differential-privacy-library/actions/workflows/general.yml)
88
[![Documentation Status](https://readthedocs.org/projects/diffprivlib/badge/?version=latest)](https://diffprivlib.readthedocs.io/en/latest/?badge=latest)
9-
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/IBM/differential-privacy-library.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/IBM/differential-privacy-library/context:python)
9+
[![CodeQL](https://github.com/IBM/differential-privacy-library/actions/workflows/codeql.yml/badge.svg)](https://github.com/IBM/differential-privacy-library/actions/workflows/codeql.yml)
1010
[![codecov](https://codecov.io/gh/IBM/differential-privacy-library/branch/main/graph/badge.svg)](https://codecov.io/gh/IBM/differential-privacy-library)
1111

1212
Diffprivlib is a general-purpose library for experimenting with, investigating and developing applications in, differential privacy.
@@ -17,7 +17,7 @@ Use diffprivlib if you are looking to:
1717
- Explore the impact of differential privacy on machine learning accuracy using classification and clustering models
1818
- Build your own differential privacy applications, using our extensive collection of mechanisms
1919

20-
Diffprivlib supports Python versions 3.7 to 3.10.
20+
Diffprivlib supports Python versions 3.8 to 3.10.
2121

2222
## Getting started: [Machine learning with differential privacy in 30 seconds](https://github.com/IBM/differential-privacy-library/blob/main/notebooks/30seconds.ipynb)
2323
We're using the [Iris dataset](https://archive.ics.uci.edu/ml/datasets/iris), so let's load it and perform an 80/20 train/test split.

diffprivlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
from diffprivlib import tools
3030
from diffprivlib.accountant import BudgetAccountant
3131

32-
__version__ = '0.6.dev0'
32+
__version__ = '0.6.0'

diffprivlib/accountant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def check(self, epsilon, delta):
307307
return True
308308

309309
raise BudgetError(f"Privacy spend of ({epsilon},{delta}) not permissible; will exceed remaining privacy budget."
310-
f"Use {self.__class__.__name__}.{self.remaining.__name__}() to check remaining budget.")
310+
f" Use {self.__class__.__name__}.{self.remaining.__name__}() to check remaining budget.")
311311

312312
def remaining(self, k=1):
313313
"""Calculates the budget that remains to be spent.

notebooks/30seconds.ipynb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@
4545
"name": "stderr",
4646
"output_type": "stream",
4747
"text": [
48-
".../site-packages/diffprivlib/models/naive_bayes.py:102: PrivacyLeakWarning: Bounds have not been specified and will be calculated on the data provided. This will result in additional privacy leakage. To ensure differential privacy and no additional privacy leakage, specify bounds for each dimension.\n",
49-
" \"privacy leakage, specify bounds for each dimension.\", PrivacyLeakWarning)\n"
48+
".../site-packages/diffprivlib/models/naive_bayes.py:107: PrivacyLeakWarning: Bounds have not been specified and will be calculated on the data provided. This will result in additional privacy leakage. To ensure differential privacy and no additional privacy leakage, specify bounds for each dimension.\n",
49+
" warnings.warn(\"Bounds have not been specified and will be calculated on the data provided. This will \"\n"
5050
]
5151
},
5252
{
5353
"data": {
54+
"text/html": [
55+
"<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>GaussianNB(accountant=BudgetAccountant(spent_budget=[(1.0, 0)]),\n",
56+
" bounds=(array([4.3, 2. , 1. , 0.1]), array([7.9, 4.4, 6.9, 2.5])))</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">GaussianNB</label><div class=\"sk-toggleable__content\"><pre>GaussianNB(accountant=BudgetAccountant(spent_budget=[(1.0, 0)]),\n",
57+
" bounds=(array([4.3, 2. , 1. , 0.1]), array([7.9, 4.4, 6.9, 2.5])))</pre></div></div></div></div></div>"
58+
],
5459
"text/plain": [
5560
"GaussianNB(accountant=BudgetAccountant(spent_budget=[(1.0, 0)]),\n",
5661
" bounds=(array([4.3, 2. , 1.1, 0.1]), array([7.9, 4.4, 6.9, 2.5])))"
@@ -176,7 +181,7 @@
176181
],
177182
"metadata": {
178183
"kernelspec": {
179-
"display_name": "Python 3",
184+
"display_name": "Python 3 (ipykernel)",
180185
"language": "python",
181186
"name": "python3"
182187
},
@@ -190,7 +195,7 @@
190195
"name": "python",
191196
"nbconvert_exporter": "python",
192197
"pygments_lexer": "ipython3",
193-
"version": "3.6.8"
198+
"version": "3.9.7"
194199
}
195200
},
196201
"nbformat": 4,

notebooks/accountant.ipynb

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)