0% found this document useful (0 votes)
44 views1 page

Tipper Terminal

The document shows how to create a fuzzy inference system (FIS) in R to determine a tip amount based on the quality of service and food. Variables for service, food, and tip amount are added to the FIS and membership functions are defined. Rules are then added to relate the input and output variables, such as poor service or rancid food leading to a cheap tip. The FIS is evaluated on sample data and its surface is generated.

Uploaded by

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

Tipper Terminal

The document shows how to create a fuzzy inference system (FIS) in R to determine a tip amount based on the quality of service and food. Variables for service, food, and tip amount are added to the FIS and membership functions are defined. Rules are then added to relate the input and output variables, such as poor service or rancid food leading to a cheap tip. The FIS is evaluated on sample data and its surface is generated.

Uploaded by

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

> fis= newfis('tipper')

> fis= addvar(fis, 'input', 'service', c(0,10))


> fis= addvar(fis, 'input', 'food', c(0,10))
> fis= addvar(fis, 'output', 'tip', c(0,30))
> fis= addmf(fis, 'input', 1, 'poor', 'gaussmf', c(1.5,0))
> fis= addmf(fis, 'input', 1, 'good', 'gaussmf', c(1.5,5))
> fis= addmf(fis, 'input', 1, 'excellent', 'gaussmf', c(1.5,10))
> fis= addmf(fis, 'input', 2, 'rancid', 'trapmf', c(0,0,1,3))
> fis= addmf(fis, 'input', 2, 'delicious', 'trapmf', c(7,9,10,10))
> fis= addmf(fis, 'output', 1, 'cheap', 'trimf', c(0,5,10))
> fis= addmf(fis, 'output', 1, 'average', 'trimf', c(10,15,20))
> fis= addmf(fis, 'output', 1, 'generous', 'trimf', c(20,25,30))
> rules= rbind(c(1,1,1,1,2), c(2,0,2,1,1), c(3,2,3,1,2))
> fis= addrule(fis, rules)
> showrule(fis)
1. If (service is poor) or (food is rancid) then (tip is cheap) (1)
2. If (service is good) then (tip is average) (1)
3. If (service is excellent) or (food is delicious) then (tip is generous) (1)
> fis=addrule(fis,c(2,2,1,1,1))
> showrule(fis)
1. If (service is poor) or (food is rancid) then (tip is cheap) (1)
2. If (service is good) then (tip is average) (1)
3. If (service is excellent) or (food is delicious) then (tip is generous) (1)
4. If (service is good) and (food is delicious) then (tip is cheap) (1)
> evalfis(rbind(c(3,5), c(2,7)), fis)
[,1]
[1,] 12.218379
[2,] 7.788532
> gensurf(fis)

You might also like