Skip to content

unifr-fss/fuzzy-tutorial

Repository files navigation

Fuzzy logic tutorial

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.

Requirements

Python version 3.9, 3.10, or 3.11 (3.12 not yet supported).

Installation

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.

Linux / macOS setup

  1. Verify your Python version:
python3 --version
  1. Create a virtual environment:
python3 -m venv venv
  1. Activate the virtual environment:
source venv/bin/activate
  1. Install libraries

With the virtual environment activated, install the required dependencies:

pip install --upgrade pip
pip install -r requirements.txt
pip install jupyterlab
  1. Start JupyterLab:
jupyter lab

This should open a local web interface (or display a URL) for JupyterLab, where you can access the tutorial notebooks.

Windows setup

As an alternative use WSL2 (Windows Subsystem for Linux) and apply the steps from the Linux step. Otherwise, continue:

  1. Verify your Python version:
python --version
  1. Create a virtual environment:
python -m venv venv
  1. Activate the virtual environment:
venv\Scripts\activate
  1. Install libraries

With the virtual environment activated, install the required dependencies:

pip install --upgrade pip
pip install -r requirements.txt
pip install jupyterlab
  1. 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.

Docker

If you encounter issues with the setup above, you can use Docker to run the environment.

  1. Build the Docker image

This command will build a Docker image and install the necessary libraries:

docker build -t fuzzy-notebook:latest .
  1. 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%.

  1. 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.

Tutorials

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.

Deliverable

After completing the tutorials, create your own Jupyter notebook applying one of the approaches to a problem.

  1. Select a domain: choose a domain related to your group project (if already available) or a personal interest.
  2. Create and name your notebook: experiment with the chosen approach and save your notebook as 03_<YourProjectName>.ipynb.
  3. Push to your repository: upload your completed notebook to your GitHub repository (including the output).