0% found this document useful (0 votes)
15 views3 pages

Project DIP

The experiment focused on implementing fuzzy logic for predicting tips based on the quality of food and service at a restaurant. It involved creating fuzzy membership functions, defining inference rules, and simulating a control system using Python's skfuzzy library. The results demonstrated how fuzzy logic can effectively model human-like decision-making in uncertain situations.

Uploaded by

shakibtuhin8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Project DIP

The experiment focused on implementing fuzzy logic for predicting tips based on the quality of food and service at a restaurant. It involved creating fuzzy membership functions, defining inference rules, and simulating a control system using Python's skfuzzy library. The results demonstrated how fuzzy logic can effectively model human-like decision-making in uncertain situations.

Uploaded by

shakibtuhin8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment No : 04

Experiment Name :

Implementation of Fuzzy Logic ,Variables and Rules for Tip Prediction

Objectives:

I. To understand the concept of fuzzy logic and fuzzy variables.


II. To create fuzzy membership functions using skfuzzy in Python.
III. To define rules for fuzzy inference based on input variables.

Theory :
Fuzzy logic is a type of logic that tries to model human reasoning. Unlike traditional or classical logic
where things are either true or false (0 or 1), fuzzy logic works with degrees of truth. This means a
value can be partly true and partly false at the same time. For example, instead of saying "The weather
is hot" (true or false), fuzzy logic can say "The weather is 70% hot and 30% not hot."This type of logic
is especially useful in situations where decisions are not black and white, but rather fall into a gray
area—like deciding how much tip to give at a restaurant. People don’t always give the same tip
percentage. It depends on the quality of food and service, and both of these factors can be good, bad, or
something in between.In our lab, we used fuzzy logic to build a tipping system using Python and the
scikit-fuzzy (skfuzzy) library. The system takes two inputs:

 Quality of the food


 Service of the staff
Both inputs are rated from 0 to 10. We divided these into fuzzy categories:
 Quality: 'poor', 'acceptable', and 'amazing'
 Service: 'bad', 'decent', and 'great'
We also defined the output, which is the tip amount, ranging from 0 to 25. The output was also divided
into fuzzy categories:

 Tip: 'low', 'medium', and 'high'


We used triangular membership functions (fuzz.trimf) to define these fuzzy sets. A triangular function
is a simple function that increases, stays at the top for a moment, then decreases. It is shaped like a
triangle. These functions help us map the crisp input values (like quality = 6.5) into fuzzy values (like
"mostly acceptable").
After defining fuzzy sets, we created fuzzy rules using logical operators like AND ( & ) and OR ( | ). For
example:

 If quality is poor OR service is bad, then tip should be low.


 If service is decent, then tip should be medium.
 If quality is amazing OR service is great, then tip should be high.
These rules are similar to how a human would think when deciding a tip. Finally, we created a control
system using these rules and simulated it by giving some example inputs. The system calculated the tip
using fuzzy logic and gave an output that is more realistic and flexible compared to fixed rules.
This fuzzy approach makes the system smarter and more adaptable to real-world conditions where
everything is not simply good or bad, but somewhere in between.

Discussion :
In this lab, we successfully used fuzzy logic to simulate a real-life decision-making system: deciding
how much tip to give at a restaurant. We created fuzzy variables for quality and service as inputs and tip
as the output. Each variable was assigned membership functions using the triangular shape, which helped
convert crisp input values into fuzzy values.
We then created three fuzzy rules that combine the conditions of quality and service to determine the
appropriate tip. For example, if the service is great or the quality of food is amazing, the system suggests
a high tip. This way, the system behaves more like a human, making decisions that consider multiple
factors.
After setting up the control system and giving inputs (e.g., quality = 6.5 and service = 9.8), we used
the .compute() function to get the tip amount. The output showed a reasonable tip value, which was also
visualized using graphs. This showed how fuzzy logic can deal with uncertainty and provide smart
solutions in uncertain situations.

Conclusion :
From this experiment, we learned how fuzzy logic can be applied in practical systems to make human-
like decisions. We understood how to define fuzzy sets, create membership functions, and build rules for
inference. Using Python and the skfuzzy library, we developed a complete fuzzy control system for tip
calculation.
This lab helped us see the power of fuzzy logic in solving real-world problems where inputs are not fixed.
It also improved our understanding of fuzzy systems and how they can be used in artificial intelligence
and decision support systems.

You might also like