To run the code included in this tutorial, we will leverage on a pretty "standard" Python/PyData stack:
numpy, pandas, matplotlib, and scikit-learn for all the data science and Machine learning parts,
and pytorch (w/ torchvision) for the Deep Learning examples.
Moreover, a few extra / specialised packages will be also featured:
- Opacus: A library to train PyTorch models with differential privacy
- PHE: A Python 3 library implementing the Paillier Partially Homomorphic Encryption
- Flower: A Federated Learning library for PyTorch
As for the Python version/distribution: any Python 3.10+ version should be fine.
I would recommend using Anaconda Distribution to have immediate access to all the main required packages, regardless of the platform/OS you are on, and to easily install the extra ones.
The repository contains the files to
recreate the Conda Environment (i.e. environment.yml)
with all the required packages.
Read "Set up the Environment" section for detailed instructions on how to proceed.
Alternatively you could use Anaconda Notebooks to run all the code, and without needing to install anything at all on your computer.
Please see "Using Anaconda Notebooks" section for further information on how to get started.
If you decided to give Anaconda Notebooks a go, you can skip this section entirely, and jump to the Anaconda Notebooks Section.
Before we start:
All the instructions reported below will consider the Terminal and hence the command-line interface to run all the commands. Similarly, one could use in alternative GitHub Desktop and Anaconda Navigator to interact with GitHub repositories, and conda environment, respectively.
If you haven't already, let's download (or git clone) the current repository on your local computer.
git clone https://github.com/leriomaggio/ppml-tutorial
cd ppml-tutorialSetup the environment:
The repository contains an environment.yml file that can be used to automatically recreate the
conda environment with all the required packages:
👉 non-Mac Silicon users
conda env create -f environment.yml👉 Mac Silicon users only: Not all libraries might be available for Mac Silicon. Adding a prefix allows to to create a conda environment on Intel libs.
CONDA_SUBDIR=osx-64 conda env create -f environment.ymlOnce this is complete, you should now have a new conda environment named ppml.
To double check that you can run the following command:
conda env listThis command lists all the available conda environment you have on your computer.
The new ppml environment should be in that list.
If that completes successfully, all you need to do now is to activate the new environment:
conda activate ppmlAlternatively, you could install all the required packages using pip:
pip install -f ppml_requirements.txtAll notebooks in this tutorial are self-contained: any specific package that is not already part of Anaconda Distribution can be installed directly from the notebook.
All you'd need is just sign up to get your account
SPECIAL CODE: Use the Code SCIPY23 to get special access to 30-days free trial to the
Starter Tier (valid until August 18th, 2023).
All the notebooks listed in the TOC include a special badge
to automatically import, and open the notebook on Anaconda.cloud.
2023-07): anaconda-panel-2023.07-py310
Anaconda Notebook badges can be generated for your notebooks using the Anaconda Badge Generator app on PyScript.com.
If you're using Anaconda Notebooks, click on the following badge
to open the
Get-Ready.ipynb notebook on anaconda.cloud and check your environment.
If you followed all the steps reported in the previous section to setup your local machine, you should be ready to proceed with testing your environment.
To do so, please open the Get-Ready.ipynb notebook to check that everything works properly on your end:
jupyter notebook Get-Ready.ipynb