Home/Blog/Programming/Demystifying Fuzzy Inference Systems
Home/Blog/Programming/Demystifying Fuzzy Inference Systems

Demystifying Fuzzy Inference Systems

Malik Jahan
Jan 11, 2024
7 min read

Become a Software Engineer in Months, Not Years

From your first line of code, to your first day on the job — Educative has you covered. Join 2M+ developers learning in-demand programming skills.

Fuzzy logic aims to model situations where we need to capture the partial truthfulness of a given proposition. Unlike the two possible truthfulness values (1 or 0) in boolean logic, we may represent the truthfulness value between 0 and 1 (both included). For a basic understanding of fuzzy logic, you may explore the blog Demystifying Fuzzy Logic: A Beginner’s Guide on the Educative platform.

We may model decision support systems using fuzzy logic to represent the underlying inputs, outputs, and the relationships between inputs and outputs.

Fuzzy vs boolean decision
Fuzzy vs boolean decision

Steps to build a fuzzy inference system#

A fuzzy inference system is built to enable decision support in a particular domain where capturing the underlying logic is not concrete. In fuzzy inference systems, inputs and outputs are modeled as fuzzy variables. The value of each of the variables is modeled as a fuzzy membership function. The rules of the application domain are identified and enumerated. In each fuzzy rule, fuzzy variables and their corresponding fuzzy values are used, depicting the underlying principles of the application domain. The following steps are performed to model such systems:

  1. The fuzzification of inputs

  2. The application of fuzzy operators on the antecedents of fuzzy rules

  3. The implication from antecedents to the consequents of fuzzy rules

  4. The aggregation of the consequents of fuzzy rules

  5. The defuzzification to compute the output

These steps have been summarized in the following figure:

Steps to build a fuzzy inference system
Steps to build a fuzzy inference system

Building a need-based financial support system#

Let’s look at an example where we’ll build a fuzzy inference system to determine the percentage of the tuition fee to be waived for a university student who has disclosed both their monthly household income and the net worth of family assets in dollars.

The identification of fuzzy variables and their corresponding values#

There are two input variables involved in this process:

  • Monthly household income (income)
  • Net worth of family assets (assets)

There is one output variable in this system:

  • Financial support to be determined as the percentage of the tuition fee to be waived (support)

For the sake of simplicity, we are categorizing each of the variables into one of three fuzzy values, listed below:

  • income can be low, medium, or high.
  • assets can be weak, average, or strong.
  • support can be low, average, or high.

The fuzzy (linguistic) values of each of the variables have been modeled below:

canvasAnimation-image
1 of 3

Now, let’s define the fuzzy rules based on these fuzzy variables.

The identification of fuzzy rules#

Based on the identified fuzzy variables and their corresponding values, a list of fuzzy rules is extracted from the application domain, which is supposed to depict the business logic. We will use the following three rules in our example:

  • If income is low AND assets are weak, then support is high.
  • If income is medium OR assets are average, then support is average.
  • If income is high AND assets are strong, then support is low.

Inference algorithm#

The following steps are performed to infer the output from the given inputs:

The fuzzification of the inputs#

We’re going to explore how the fuzzy inference algorithm works by using it to calculate a university student’s tuition fee reduction. For this purpose, let’s suppose that the user enters the following inputs:

  • income = 3,200 dollars
  • assets = 200,000 dollars

The first step is to fuzzify the inputs. Membership values of the inputs are computed in each of the membership functions, as shown below:

Fuzzification of the input variable income
Fuzzification of the input variable income

The membership value μ\mu of the input of income in each membership function of its variable has been given below:

  • μlow(3,200)=0.80\mu_{low}(3,200) = 0.80
  • μmedium(3,200)=0.46\mu_{medium}(3,200) = 0.46
  • μhigh(3,200)=0\mu_{high}(3,200) = 0
Fuzzification of the input variable assets
Fuzzification of the input variable assets

Similarly, the membership value μ\mu of the input of assets in each membership function of its variable has been given below:

  • μweak(200,000)=0.99\mu_{weak}(200,000) = 0.99
  • μaverage(200,000)=0\mu_{average}(200,000) = 0
  • μstrong(200,000)=0\mu_{strong}(200,000) = 0

The application of fuzzy operators on the antecedents of fuzzy rules#

We have three fuzzy rules defined in this example. The fuzzy operators are applied on the antecedents of each rule using the membership values computed during the fuzzification process. The outcome of this step on each rule has been given below:

Rule-1#

The antecedent of rule-1 is income is low AND assets are weak. It results in the following computation:

μlow(income)\mu_{low}(income) AND μweak(assets)=min(μlow(income),μweak(assets))=min(0.80,0.99)=0.80\mu_{weak}(assets) = min(\mu_{low}(income), \mu_{weak}(assets)) = min(0.80, 0.99) = 0.80

This step results in 0.80 as the strength value of the antecedent of rule-1.

Rule-2#

The antecedent of rule-2 is income is medium OR assets are average. It results in the following computation:

μmedium(income)\mu_{medium}(income) OR μaverage(assets)=max(μmedium(income),μaverage(assets))=max(0.46,0)=0.46\mu_{average}(assets) = max(\mu_{medium}(income), \mu_{average}(assets)) = max(0.46, 0) = 0.46

This step results in 0.46 as the strength value of the antecedent of rule-2.

Rule-3#

The antecedent of rule-3 is income is high AND assets are strong. It results in the following computation:

μhigh(income)\mu_{high}(income) AND μstrong(assets)=min(μhigh(income),μstrong(assets))=min(0,0)=0\mu_{strong}(assets) = min(\mu_{high}(income), \mu_{strong}(assets)) = min(0, 0) = 0

This step results in 0 as the strength value of the antecedent of rule-3.

The aggregation of the consequents of fuzzy rules#

The strength values of all rules are applied to the membership functions of the respective consequents. It results in outputting the area of the respective membership function of the output variable. Following are the exact cut points of all of the membership functions of the output variable used in this example:

  • Membership function high of support is cut at 0.80.
  • Membership function average of support is cut at 0.46.
  • Membership function low of support is cut at 0.

The areas under respective cuts of all membership functions are aggregated together, as shown below:

Aggregation of the consequents of fuzzy rules
Aggregation of the consequents of fuzzy rules

In this figure, the blue lines represent the cut points of the consequents, and the red-shaded area represents the aggregated output space.

The defuzzification of the output space to compute the actual output#

Appropriate defuzzification methods need to be chosen and applied to the output space to decode the exact output of the question. There are different defuzzification methods available in the literature, including centroid, bisection, largest of maxima, smallest of maxima, and middle of maxima. Centroid is one of the more popular defuzzification methods. It computes the geometric center of the output space.

The green bubble in the following diagram shows the centroid. It is dropped to the horizontal axis to map it to the actual output shown as the green arrow. The output is 70%.

Defuzzification to find the output
Defuzzification to find the output

Conclusion#

A fuzzy inference system is one of the most powerful choices to model decision support systems in different application domains. When the possible values of the variables are linguistic concepts, then the overlap between the linguistic values is inherent in the application domain. Fuzzy modeling is an attractive choice to capture such inherent ambiguity in the application domain. There is a wide variety of potential applications where fuzzy inference systems may be applied, including:

  • Automatic speed control systems for vehicles
  • Altitude controls of spacecraft
  • Intelligent decision support systems in business intelligence
  • Evaluation systems to grant loans in financial organizations
  • Optimization in the manufacturing industry
  • Medical diagnostic support systems
  • Handwriting recognition systems

Moving forward#

Explore more machine learning and artificial intelligence courses, like the ones below:

Mastering Machine Learning Theory and Practice

Cover
Mastering Machine Learning Theory and Practice

The machine learning field is rapidly advancing today due to the availability of large datasets and the ability to process big data efficiently. Moreover, several new techniques have produced groundbreaking results for standard machine learning problems. This course provides a detailed description of different machine learning algorithms and techniques, including regression, deep learning, reinforcement learning, Bayes nets, support vector machines (SVMs), and decision trees. The course also offers sufficient mathematical details for a deeper understanding of how different techniques work. An overview of the Python programming language and the fundamental theoretical aspects of ML, including probability theory and optimization, is also included. The course contains several practical coding exercises as well. By the end of the course, you will have a deep understanding of different machine-learning methods and the ability to choose the right method for different applications.

36hrs
Beginner
109 Playgrounds
10 Quizzes

Grokking AI for Engineering & Product Managers

Cover
Grokking AI for Engineering & Product Managers

In one form or the other, AI is going to be infused in all the tech products. Meaning, that in order to stay a relevant leader, it has become essential to have a solid, broad understanding of AI. While you may not be implementing the solution, you need to speak the language of AI. Whether you’re leading a team on creating AI solutions, or you just want a better understanding of AI, then this course is for you. In this course, I have deconstructed the concepts most relevant for you. You will start by learning the basics of AI, its connection with machine learning, and the different types of algorithms you should be familiar with. You’ll then learn the rules, best practices, and infrastructure for creating great AI products that users trust. Then, you will go through some real case studies of AI application and do a deep dive into Ethical AI. You'll end by getting an outlook into the current status and future of AI. In a nutshell, this course is your no-fuss, comprehensive guide to the essentials of AI.

5hrs
Beginner
3 Quizzes
111 Illustrations

Getting Started with Image Classification with PyTorch

Cover
Getting Started with Image Classification with PyTorch

PyTorch is a machine learning framework used in a wide array of popular applications, including Tesla’s Autopilot and Pyro, Uber’s probabilistic modeling engine. This course is an introduction to image classification using PyTorch’s computer vision models for training and tuning your own model. You’ll start with the fundamental concepts of applying machine learning and its applications to image classification before exploring the process of training your AI model. You’ll prepare data for intake by the computer vision model with image pre-processing, set up pipelines for training your model, and fine-tune the variables to improve predictive performance. You’ll finish by deploying the image classification model by converting to ONNX format and serving it via REST API. By the end of this course, you’ll be able to build and deploy your own image classification models from scratch.

6hrs
Beginner
110 Playgrounds
6 Quizzes

Frequently Asked Questions

What are the two types of FIS?

The two types of FIS are as follows:

  • Mamdani-type fuzzy inference system: Widely used for control systems and decision-making, it’s known for its intuitive, human-readable rule format.
  • Sugeno-type fuzzy inference system: Often used in mathematical modeling and optimization, it provides a more systematic and computationally efficient output formulation.

  

Free Resources