Installation guide

In this notebook, we will guide you through the installation of the necessary tools for this course.

python

The coding part of this couse will be based on python through Jupyter notebooks. You have two options here:

  • Work online through Google Colab. The advantage here is that you won’t need to install anything locally (sometimes a hassle…). You will also have access to cloud computing, which may be beneficial for training larger models. The drawback is that some of the libraries will need to be reinstalled every time you restart a notebook. Also, you won’t be able to work here without an internet connection.
  • Local installation. This will take a little bit longer to set up (5 mins?, see below), but is preferable in the long run, as you will have greater control over your files and installations.

Installing Python and Jupyter notebooks

There are different options here, the recommended ones are Anaconda (see installation guide here) or Visual Studio Code (see guide here).

Getting git ready

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. We will use it to “clone” and “pull” notebooks from the course repositories. You have again a few options: 1) the usual one is directly installting git (see this guide). If you are not confortable using the terminal, we recommend the use of Github Desktop.

Getting the course resources ready

Now that you have everything installed, you are ready to get the course resources.

lectures_ml library

Note: you can skip this step if you will be working via Google Colab

First, we will install the library lectures_ml, which provides access to different functions and tools that will be used throughout our course. In your terminal (in case you are on Windows, make sure you are in the Anaconda terminal, not the Windows shell), run the following:

pip install git+https://github.com/BorjaRequena/Machine-Learning-Course.git

This may take a bit, as this will also install many other libraries (e.g. pytorch, scikit_learn, etc) that will be used during the course. To test that everything went fine, you can run the following cell. Note that you need to restart the kernel after installing the libraries for this cell to work:

# Test cell, run this to see if the libraries are correctly installed. sklearn sometimes gives some errors.
#If it didn't install correctly but the others did, install it via pip: pip install scikit-learn

try:
    import lectures_ml
    print('lectures_ml good!')
except ImportError:
    raise AssertionError("Library 'lectures_ml' is not installed.")

try:
    import torch
    print('torch good!')
except ImportError:
    raise AssertionError("Library 'torch' is not installed.")

try:
    import sklearn
    print('sklearn good!')
except ImportError:
    raise AssertionError("Library 'sklearn' is not installed. Install manually if needed via pip install scikit-learn")
lectures_ml good!
torch good!
sklearn good!

ML4Phys_UIBK_W25 repo

This repository contains the notebooks that we will follow throughout the course. You have two ways of accessing it:

  • If you are planning to work via Google Colab, you can go to the course’s webpage and follow the links redirecting to Colab at the beginning of each section’s page.

  • If you will be working locally, clone the repository using:

git clone https://github.com/gorkamunoz/ML4Phys_UIBK_W25

This repository will be update regularly with each week’s course content. Hence, be sure to git pull the repository before each lecture.

Important: if you edit some of the notebooks (e.g. by doing the exercises), you will end up having some git conflicts. To avoid this, we recommend you to copy+paste this repo in a different folder, and call it e.g. ML4Phys_student. Use this new notebook to do the exercises, while keeping the original untouched. Follow the procedure above to pull from the original repo. Whenever a new notebook appears, paste it in your “student” folder. This is a “dirty” solution, git indeed gives you access to tools to this properly.

fastai library

Aside of the libraries in the requirements of lectures_ml, we will also need fastai. You can install it using pip install fastai.