This tutorial is part of the course Fuzzy Sets and Systems
for the Swiss Joint Master of Science in Computer Science.
It introduces the use of fuzzy logic algorithms in Python,
utilizing the scikit-fuzzy
library.
The tutorial instructions are based on examples provided by the scikit-fuzzy
library.
Python version 3.9, 3.10, or 3.11 (3.12 not yet supported).
Note
This guide assists in setting up JupyterLab and Python dependencies. If you're already comfortable with Python, feel free to use your preferred setup process.
First, fork and clone this repository, or download it manually to your computer. Then open a terminal inside the repository and proceed.
- Verify your Python version:
python3 --version
- Create a virtual environment:
python3 -m venv venv
- Activate the virtual environment:
source venv/bin/activate
- Install libraries
With the virtual environment activated, install the required dependencies:
pip install --upgrade pip
pip install -r requirements.txt
pip install jupyterlab
- Start JupyterLab:
jupyter lab
This should open a local web interface (or display a URL) for JupyterLab, where you can access the tutorial notebooks.
As an alternative use WSL2 (Windows Subsystem for Linux) and apply the steps from the Linux step. Otherwise, continue:
- Verify your Python version:
python --version
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
venv\Scripts\activate
- Install libraries
With the virtual environment activated, install the required dependencies:
pip install --upgrade pip
pip install -r requirements.txt
pip install jupyterlab
- Start JupyterLab:
jupyter lab
This command should open a local web interface (or display a URL) for JupyterLab, where you can access the tutorial notebooks.
If you encounter issues with the setup above, you can use Docker to run the environment.
- Build the Docker image
This command will build a Docker image and install the necessary libraries:
docker build -t fuzzy-notebook:latest .
- Run the Docker container:
Use the following command to start the JupyterLab server in a Docker container:
docker run -it --rm -p 10000:8888 -v "${PWD}":/home/jovyan/work fuzzy-notebook:latest
If you are on Windows (without WSL), replace "${PWD}"
with %cd%
.
- Access JupyterLab:
Open your browser and go to http://localhost:10000/lab?token=YOUR_TOKEN_IN_CONSOLE (note the port 10000
).
Replace YOUR_TOKEN_IN_CONSOLE
with the token displayed in your terminal after running the container.
Start with the Introduction, which provides an overview of fuzzy logic concepts and terminology. This is recommended as the first step.
This course includes two tutorial notebooks:
- 01_FuzzyControlSystem.ipynb: Introduction to fuzzy control systems.
- 02_FuzzyClustering.ipynb: Introduction to fuzzy clustering techniques.
Work through these notebooks in order.
After completing the tutorials, create your own Jupyter notebook applying one of the approaches to a problem.
- Select a domain: choose a domain related to your group project (if already available) or a personal interest.
- Create and name your notebook: experiment with the chosen approach and save your notebook as
03_<YourProjectName>.ipynb
. - Push to your repository: upload your completed notebook to your GitHub repository (including the output).