Debian Codegraph @

examples/takagi-sugeno/octave/linear_tip_calculator.R

raw
1 #Code automatically generated with fuzzylite 6.0.
2
3 library(ggplot2);
4
5 engine.name = "linear_tip_calculator"
6 engine.fll = "Engine: linear_tip_calculator
7 InputVariable: FoodQuality
8 enabled: true
9 range: 1.000 10.000
10 lock-range: false
11 term: Bad Trapezoid 0.000 1.000 3.000 7.000
12 term: Good Trapezoid 3.000 7.000 10.000 11.000
13 InputVariable: Service
14 enabled: true
15 range: 1.000 10.000
16 lock-range: false
17 term: Bad Trapezoid 0.000 1.000 3.000 7.000
18 term: Good Trapezoid 3.000 7.000 10.000 11.000
19 OutputVariable: Tip
20 enabled: true
21 range: 10.000 20.000
22 lock-range: false
23 aggregation: none
24 defuzzifier: WeightedAverage TakagiSugeno
25 default: nan
26 lock-previous: false
27 term: TenPercent Linear 0.000 0.000 10.000
28 term: FifteenPercent Linear 0.000 0.000 15.000
29 term: TwentyPercent Linear 0.000 0.000 20.000
30 RuleBlock:
31 enabled: true
32 conjunction: Minimum
33 disjunction: none
34 implication: none
35 activation: General
36 rule: if FoodQuality is Bad and Service is Bad then Tip is TenPercent
37 rule: if FoodQuality is Bad and Service is Good then Tip is FifteenPercent
38 rule: if FoodQuality is Good and Service is Bad then Tip is FifteenPercent
39 rule: if FoodQuality is Good and Service is Good then Tip is TwentyPercent"
40
41 engine.fldFile = "linear_tip_calculator.fld"
42 if (require(data.table)) {
43 engine.df = data.table::fread(engine.fldFile, sep="auto", header="auto")
44 } else {
45 engine.df = read.table(engine.fldFile, header=TRUE)
46 }
47
48 engine.plot.i1i2_o1 = ggplot(engine.df, aes(FoodQuality, Service)) +
49 geom_tile(aes(fill=Tip)) +
50 scale_fill_gradient(low="yellow", high="red") +
51 stat_contour(aes(x=FoodQuality, y=Service, z=Tip), color="black") +
52 ggtitle("(FoodQuality, Service) = Tip")
53
54 engine.plot.i2i1_o1 = ggplot(engine.df, aes(Service, FoodQuality)) +
55 geom_tile(aes(fill=Tip)) +
56 scale_fill_gradient(low="yellow", high="red") +
57 stat_contour(aes(x=Service, y=FoodQuality, z=Tip), color="black") +
58 ggtitle("(Service, FoodQuality) = Tip")
59
60 if (require(gridExtra)) {
61 engine.plots = arrangeGrob(engine.plot.i1i2_o1, engine.plot.i2i1_o1, ncol=2, top=engine.name)
62 ggsave(paste0(engine.name, ".pdf"), engine.plots)
63 if (require(grid)) {
64 grid.newpage()
65 grid.draw(engine.plots)
66 }
67 }