Fuzzy Modelling Using Python
Fuzzy Modelling Using Python
PYTHON
Mayanck Bihani
(312216114064)
Step 1: Installing PYTHON
From https://www.anaconda.com/distribution/, download
Python, version 3.7
Step 2
From the start button, search and open the “Anaconda Prompt”, which
is a command prompt developed by Anaconda.
In that, type “conda update jupyter”
It will ask for a prompt, “Install all packages y/n.” Press y
This will automatically install the Jupyter notebook in the system
Video for Python and Jupyter installation
Familiarizing With Jupyter Integrated
Development Environment (IDE)
• To get started, you can either type ‘jupyter notebook’ in the anaconda
command prompt, or directly search for the same from the start
menu.
The Notebook will open in a browser
From the top right corner, select New -> Python 3
• Code can be typed in the boxes line by line.
• To compile, press “Shift+Enter’
Video For Familiarizing With Jupyter IDE
Step 3: Installing Modules required to run
Fuzzy in Python
• After familiarizing yourself with the environment, download and
install “skfuzzy,” the module required to run fuzzy logic in python
• To do that, in the Anaconda command Prompt, type in “pip install
scikit-fuzzy” and press enter
Step 4: Fuzzy Code
• After installing the scikit-fuzzy module, open a new python 3 jupyter
notebook, and in the first block, type in the following commands:
The np.arange command takes in two arguments: the lower and the upper limits of the scope of the values,
and creates an array of integers starting from the lower value and ending at the number preceding the upper
value
6. Torque :
1. 0-10 : ulow
2. 10-20 : vlow
3. 20-30 : low
..
9. 90-100 : uhigh
Defining The Fuzzy Inference System Rules
• Now, convert the numerical values obtained from the experiment to
linguistic terms
• For Eg:
Defining The Fuzzy Inference System Rules
• Now, we write the rules in python
• FOR THRUST FORCE:
Generating the Control Environment
• After defining the rules, we generate the control environment using
control.ControlSystem([<rules list>])
Simulating the Control Environment
• The generated environment “tforce_env” is now simulated under
another variable name “tforce_sim” using
control.ControlSystemSimulation(tforce_env)
Inputting the Values
• Now that the environment has been simulated and stored under
tforce_sim, we can input the data for which fuzzy model prediction is
to be generated.
Computing the Data
Obtaining the Output:
• Similarly, the rule base for Torque can be defined, simulated and
computed.