This repository contains a set of tutorials which are the introduction for the topics covered in the subject Machine Learning II of the Master in Artificial Intelligence taught at the three universities of Galicia: University of A Coruña (UDC), University of Santiago de Compostela (USC), and University of Vigo (UVigo).
- David Mera Pérez (coordinator, USC)
- Enrique Fernández Blanco (UDC)
- David Olivieri Cecchi (UVigo)
The practical sessions will be developed via Notebooks. To run them you will need Python (>3.8), a Notebook server (e.g., Jupyter), and all the necessary packages. There are different configuration options depending on your preferences:
-
Google Colab: Run the Notebooks online and install extra libraries using commands such as
!pip install xxx. The free tier has some limitations, mainly related to computing resources. -
Python + pip + virtual environments: Install Python (>3.8) from the official website. Dependencies can be installed using
pipinside a virtual environment. -
uv: A fast Python package and environment manager that replaces conda for this course. It creates standard virtual environments and uses
pip-compatible workflows.
This project uses uv as an alternative to conda for managing Python environments and dependencies.
uv creates standard Python virtual environments, so the usual pip workflows apply.
From the root of the repository:
uv venvThis creates a standard virtual environment in .venv/.
uv does not provide its own activate command.
Activation is done using the standard Python venv scripts.
macOS / Linux
source .venv/bin/activateWindows (PowerShell)
.\.venv\Scripts\Activate.ps1With the corresponding environment activated, all dependencies are defined in requirements.txt and can be installed.
pip install -r requirements.txtSince the environment was created with
uv, thispipcommand installs packages inside the project virtual environment.
If the environment is activated:
pip install package_nameExample:
pip install riverYou can also use uv directly:
uv pip install package_nameExamples:
uv pip install river
uv pip install "flwr[simulation]"
uv pip install -r requirements.txtThis automatically installs packages into the project virtual environment (.venv).
Instead of activating the environment, you may use:
uv run commandExample:
uv run jupyter notebookThis ensures the command runs using the project virtual environment.
| Task | Recommended command |
|---|---|
| Create environment | uv venv |
| Activate environment | source .venv/bin/activate |
| Install dependencies | pip install -r requirements.txt |
| Install one package | pip install package_name |
| Install without activation | uv pip install package_name |
| Run command without activation | uv run command |
The table below summarizes the main libraries used in the course. You do not need to install them one-by-one (they are already included in requirements.txt), but this overview can help you understand what each unit relies on.
| Package | Used for | Notes |
|---|---|---|
jupyter / ipykernel |
Running notebooks locally | Optional kernel registration supported |
numpy, pandas |
Data manipulation | Core scientific stack |
matplotlib |
Plotting | Figures in notebooks |
scikit-learn==1.7.2 |
Classical ML + utilities | Pinned for River compatibility |
river |
Online learning + concept drift | Early units (Online ML) |
flwr[simulation] |
Federated learning simulations | Simulation extras required |
tensorflow |
Federated learning labs | Model training backend |
ray[default] |
Flower simulation backend | Required by Flower simulation mode |
python-graphviz |
Visualization | Some notebooks use Graphviz |
rich |
Pretty console output | Used in some examples |
To obtain the notebooks for laboratory practices, you can either download the ZIP file from GitHub or clone the repository using Git:
git clone git@github.com:ennanco/MIA_ML2.gitImportant: The examples located within the initial three working units (online ML + Concept Drift) have been specifically tailored for compatibility with River 0.22.
With the virtual environment activated, run:
jupyter notebookThen open your browser at http://localhost:8888/.
The security token will be shown in the terminal.
python -m ipykernel install --user --name mia-ml2 --display-name "Python (MIA-ML2)"This allows selecting the correct environment from within Jupyter.
- River’s wrapper module, designed for integration with libraries like scikit-learn, currently has compatibility issues. Scikit-Learn versions ≥ 1.8.0 exhibit integration problems with River, resulting in the following error in Unit02:
'super' object has no attribute '__sklearn_tags__'
Until River is updated, the recommended workaround is to downgrade scikit-learn:
pip uninstall scikit-learn
pip install "scikit-learn==1.7.2"- Always ensure you are using the
pipfrom the active virtual environment. - You may also use Google Colab if you prefer not to install anything locally.
