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 fcmpy library.
The tutorial instructions are based on examples provided by the fcmpy
library.
Python version 3.8 or Docker. The Python versions 3.9 and later ones may cause some dependencies issues and are not yet fully supported by the fcmpy
package.
However, the main functions of the package should work with versions 3.9, 3.10 and 3.11.
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.
- Verify your Python version:
python3 --version
- Create a conda environment
Change
<venv>
to your desired name.
conda create --name venv python=3.8
- Activate the virtual environment:
conda activate venv
- Install libraries
pip install -r requirements.txt
pip install jupyterlab
- Create a kernel for the jupyter notebook
python -m ipykernel install --user --name=venv --display-name "venv"
- Start Jupyter Lab
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 fcm-notebook:latest .
- Run the Docker container:
Use the following command to start the JupyterLab server in a Docker container:
docker run -it --rm -p 8888:8888 -v "${PWD}":/workspace fcm-notebook:latest
If you are on Windows (without WSL), replace "${PWD}"
with %cd%
.
- Access JupyterLab:
Click on the link that looks like http://127.0.0.1:8888/lab?token=YOUR_TOKEN
in the terminal output.
This course includes two tutorial notebooks:
- 01_FCM_Scenario.ipynb: Introduction to Fuzzy Cognitive Maps - Scenarios
- 02_FCM_ClassImportance.ipynb Introduction to Fuzzy Cognitive Maps - Class importance
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).