← Back to list

Fuzzy Logic Engine: What is it and How to Build it — Part 2

An extensive tutorial, no-code walk-through in building your own engine

Lazuardi Al-Muzaki · 2026-05-28 02:59 · 3 claps · 4.9 min read
#fuzzy-logic #decision-modeling #mcdm #streamlit #defuzzification
Open on Medium ↗

Fuzzy Logic Engine: What is it and How to Build it — Part 2

An extensive tutorial, no-code walk-through in building your own engine

Note: This article is a follow-up of the previous part which you can read first HERE.

Building Fuzzy Logic Engine for Human Resource Recruitment

Picking up where we left off, imagine that all HR representatives, as respondents, are surveyed comprehensively through a questionnaire composed of the question structure we discussed prior.

As a reminder, the questions must cover every fuzzy class except one — the lowest tier of each variable — and this applies to every variable, both input and output.

For our case, you can see how the questionnaire is designed below. The rows indicate the questions posed to respondents.

The survey questionnaire design

The survey questionnaire design

As we collect answers from all respondents, the imported spreadsheet will display each question as a column. If you have already reached this stage, and I am assuming you have come up with your own business case, we can start the fun part: developing the engine.

Playground for Building the Engine

Architecture of Fuzzy Logic (courtesy of GeeksforGeeks.com)

Architecture of Fuzzy Logic (courtesy of GeeksforGeeks.com)

For learning purposes, we have done our best to provide a convenient environment for building a fuzzy logic engine. We have taken the no-code route and built a user-friendly Streamlit app to guide you through the process following above architecture. Please click the link below to get started.

https://fuzzy-logic.streamlit.app/

Step 1: Upload your Survey Result Data

First things first, you need to upload your survey result data, or the spreadsheet exported from whichever form builder platform you used. To keep things smooth, converting the spreadsheet — normally an xlsx file — into CSV format is encouraged.

For our case of HR Recruitement, you could find the CSV and download it here

Step 2: Configure the Model Setup

Moving on to next tab of Model Setup, you will be asked to name the model first. After that, define the number of variables in total. For our purpose, we will be having 4 variables (3 input and 1 output)

Pay attention to example above. Examine for we need to fill out handful of input fields here.

  • Variable Name: For instance, gpa. A clean, lowercase name is preferable.
  • Type: Input or Output. Since we are configuring GPA, it is Input.
  • Min and Max: The allowable minimum and maximum values for that variable. For GPA, this will be 0 to 4.
  • Step: The increment that governs the granularity of the value. In this case it is 0.1, meaning any GPA value expressed to one decimal place is valid.
  • Number of Fuzzy Levels: For GPA, this is 4 as defined earlier.
  • Level Name: From Bad to Exceptional.
  • Survey Column: The mapping step, where you specify which column — that is, which question — from the loaded CSV corresponds to each level name. For the lowest-tier level, Bad in this case, no mapping is needed since there is no representing column for it. Simply select (inferred edge), and the app will derive the value range for that level automatically.

Repeat this for all remaining variables. Note that when configuring the output variable, an additional field will appear called Defuzzification, which sets the defuzzification method to be used later. For now, stick with the default value of centroid.

After that click button ‘Generate Membership from Mapping’

Step 3: Examine the Membership Graph of Fuzzification

Now the membership graph is ready for you to observe and examine. Notice that you will have a graph for every variable. What do you think? is there any interesting pattern happening?

And one thing worth noting is about a table you can see below all those graphs. Understand that we have two columns called Shape and Points. Shape explain how each level membership is established given the nature of survey data. Some are trapezoidal and some are triangular. And Points column define what you might learn about TFN (Triangular Fuzzy Number for Triangular shape, and Trapezoidal Fuzzy Number for Trapezoidal shape). It is a set of number that express the degree of subjectivity and vagueness of the value by defining a range with number of points.

Step 4: Determine the Rules

Now determining the rules is an activity to which all HR representative need to be in accordance. Some example of rules would expressed as something like this:

  • If a candidate has a Bad GPA and Rare organizational experience, then their selection chance would be Very Low.

Ideally, one rule is never enough — even two or three would fall short. Develop as many rules as possible, because we need to cover every combination of fuzzy levels across all three input variables, as well as the output.

For instance, if no rule is defined in a way that allows a candidate to achieve a Very High selection chance, then no candidate will ever be computed and plotted within that membership region during defuzzification. Likewise, if we fail to define rules that account for a scenario where GPA is Good, the fuzzy logic engine will break when it attempts to compute a score for a candidate whose GPA falls squarely within the full membership of ‘Good.’

Step 6: Simulate Candidates as you do Defuzzification

Defuzzification is the final step of building the engine. Basically, it is where everything goes full circle. Whilst in fuzzification we convert crisp input into fuzzy values, here we do the opposite. We want the output that of crisp value as we do this step.

Play along with this part of the app as you imagine how a candidate would be. Or perhaps you could try with your own gpa, organization experience and graduate status. Fill them up as the crisp input for this Fuzzy Logic Engine. Click the ‘Generate defuzzification graph’ and see the percentage of your own selection chance!.

And that is that. The Fuzzy Logic Engine and how it is capable to cater stakeholder humane language which is fuzzy and imprecise, but somehow still manage to process the crisp input into crisp output. Amazing, isn’t it.


메타데이터
post_id
083026194d9f
slug
fuzzy-logic-engine-what-is-it-and-how-to-build-it-part-2-083026194d9f
url
https://medium.com/@lazuardy.almuzaki/fuzzy-logic-engine-what-is-it-and-how-to-build-it-part-2-083026194d9f
canonical_url
https://medium.com/@lazuardy.almuzaki/fuzzy-logic-engine-what-is-it-and-how-to-build-it-part-2-083026194d9f
author_url
https://medium.com/@lazuardy.almuzaki
status
ok
fetched_at
2026-06-09 15:37:30