Practical exercises
For all of our exercises, we will be using Jupyter Notebook. Along with the book, we provide a GitHub repository at https://github.com/PacktPublishing/Graph-Machine-Learning, where all of the notebooks are provided and organized in different folders, one for each chapter of the book.
Each chapter is also based on a self-contained and separated environment, bundling all of the dependencies required to run the exercises of a given chapter. The Python version and the version of the dependencies may slightly vary depending on the set of libraries used in the chapter. Version management is implemented using Poetry, which allows us to resolve, manage, and update dependencies easily, making sure that the environments are fully reproducible.
Direct dependencies (including the Python version) are specified in each chapter/folder in the pyproject.toml
file. If you are using Poetry, you can simply install the environment by using:
poetry install
Otherwise, if you don’t have a Poetry installation on your local machine, you can also use pip
. Along with the pyproject.toml
and poetry.lock
files, we also provide a requirements.txt
file with the entire set of dependencies (also transitive) pinned to the exact version used to run the examples, which can be installed using:
pip install -r requirements.txt
Moreover, we also provide a Docker image with a Jupyter server installation integrated with the different Python environments. Each chapter’s environment is loaded as a separated kernel and the different notebooks are already configured to use the respective environment. Docker can be installed on multiple operating systems (Linux, Windows, and macOS). Please refer to the website for guidance on how to set up Docker on your system. If you are a beginner, we also suggest you install Docker Desktop for an easy-to-use graphical user interface (GUI) to interact with the Docker Engine.
Once Docker is installed, you can start the containerized image either via the GUI or using the CLI:
docker run \
-p 8888:8888 \
--name graph-machine-learning-box \
graph-machine-learning:latest
You can find more information on how to run and build the Graph Machine Learning book image in the README.md
file at https://github.com/PacktPublishing/Graph-Machine-Learning/blob/main/docker/README.md.
The image will run a Jupyter server, available at http://localhost:8888/
. The environments of the different chapters have already been configured and loaded in the Jupyter server, and they can be selected when creating a new notebook. The notebooks in the different chapters are already configured to bind to the correct kernel.