Fuzzy rule-based systems (FRBSs) are based on the fuzzy concept proposed by Zadeh in 1965, which represents the reasoning of human experts in production rules (a set of IF-THEN rules) to handle real-life problems from domains such as control, prediction and inference, data mining, bioinformatics data processing, robotics, and speech recognition. FRBSs are also known as fuzzy inference systems and fuzzy models. When applied to specific tasks, they may also be known under specific names such as fuzzy associative memories or fuzzy controllers. In this package, we consider systems with multi-inputs and single-output (MISO), with real-valued data.

FRBSs are a competitive alternative to other classic models and algorithms in order to solve classification and regression problems. Generally, an FRBS consists of four functional parts:

a fuzzification interface which transforms the crisp inputs into degrees of membership functions of the linguistic term of each variable. See

`fuzzifier`

.a knowledge base consisting of a database (DB) and a rulebase (RB). While the database includes the fuzzy set definitions, the rulebase contains fuzzy IF-THEN rules. We will represent the knowledge as a set of rules. Each one has the following structure.

`IF premise (antecedent) THEN conclusion (consequent)`

See

`rulebase`

.an inference engine which performs the inference operations on the fuzzy IF-THEN rules. There are two kinds of inference for fuzzy systems based on linguistic rules: The Mamdani and the Takagi Sugeno Kang model. See

`inference`

.a defuzzification process to obtain the crisp values from linguistic values. There are several methods for defuzzification such as the weighted average, centroid, etc. See

`defuzzifier`

.

Since it may be difficult to obtain information from human experts in the form required, an alternative and effective way to acquire the knowledge is to generate the fuzzy IF-THEN rules automatically from the numerical training data. In general, when modeling an FRBS, there are two important processes which should be conducted, namely structure identification and parameter estimation. Structure identification is a process to find appropriate fuzzy IF-THEN rules and to determine the overall number of rules. Parameter estimation is applied to tune parameters of membership functions. Many approaches have been proposed in order to perform this modeling such as a table-lookup scheme, heuristic procedures, neuro-fuzzy techniques, clustering methods, genetic algorithms, least squares methods, gradient descent, etc. In this package, the following approaches to generate fuzzy IF-THEN rules have been implemented:

FRBS based on space partition

Wang and Mendel's technique (

`WM`

): It is used to solve regression tasks. See`WM`

.Chi's technique (

`FRBCS.CHI`

): It is used to solve classification tasks. See`FRBCS.CHI`

.Ishibuchi's technique using weight factor (

`FRBCS.W`

): It is used to solve classification tasks. See`FRBCS.W`

.

FRBS based on neural networks

The adaptive-network-based fuzzy inference system (

`ANFIS`

): It is used to solve regression tasks. See`ANFIS`

.The hybrid neural fuzzy inference system (

`HYFIS`

): It is used to solve regression tasks. See`HyFIS`

.

FRBS based on clustering approach

The subtractive clustering and fuzzy c-means (

`SBC`

): It is used to solve regression tasks. See`SBC`

.The dynamic evolving neural-fuzzy inference system (

`DENFIS`

): It is used to solve regression tasks. See`DENFIS`

.

FRBS based on genetic algorithms

The Thrift's method (

`GFS.THRIFT`

): It is used to solve regression tasks. See`GFS.Thrift`

.The Genetic fuzzy systems for fuzzy rule learning based on the MOGUL methodology (

`GFS.FR.MOGUL`

): It is used to solve regression tasks. See`GFS.FR.MOGUL`

.The Ishibuchi's method based on genetic cooperative-competitive learning (

`GFS.GCCL`

): It is used to solve classification tasks. See`GFS.GCCL`

.The Ishibuchi's method based on hybridization of genetic cooperative-competitive learning (GCCL) and Pittsburgh (

`FH.GBML`

): It is used to solve classification tasks. See`FH.GBML`

.The structural learning algorithm on vague environtment (

`SLAVE`

): It is used to solve classification tasks. See`SLAVE`

.The genetic for lateral tuning and rule selection of linguistic fuzzy system (

`GFS.LT.RS`

): It is used to solve regression tasks. See`GFS.LT.RS`

.

FRBS based on the gradient descent method

The FRBS using heuristics and gradient descent method (

`FS.HGD`

): It is used to solve regression tasks. See`FS.HGD`

The fuzzy inference rules by descent method (

`FIR.DM`

): It is used to solve regression tasks. See`FIR.DM`

The functions documented in the manual for the single methods are all called internally
by `frbs.learn`

, which is the central function of the package.
However, in the documentation of each of the internal learning functions,
we give some theoretical background and references to the original literature.

**Usage of the package:**

First of all, if you have problems using the package, find a bug, or have suggestions, please contact the package maintainer by email, instead of writing to the general R lists or to other internet forums and mailing lists.

The main functions of the package are the following:

The function

`frbs.learn`

allows to generate the model by creating fuzzy IF-THEN rules or cluster centers from training data. In other words, users just need to call this function to generate an FRBS model from training data. The different algorithms mentioned above are all accessible through this function. The outcome of the function is an`frbs-object`

.Even though the main purpose of this package is to generate the FRBS models from training data automatically, we provide the function

`frbs.gen`

, which can be used to build a model manually without using a learning method. Moreover, we provide the following features: linguistic hedges, the "and" and "or" operators, and the "dont_care" value for representing the degree of 1. The higher degree of interpretability can also be achieved by using the "dont_care" value. If we want to define various length of rules in the rulebase, we can also define the "dont_care" value. See`rulebase`

.The purpose of the function

`predict`

is to obtain predicted values according to the testing data and the model (analogous to the`predict`

function that is implemented in many other R packages).There exist functions

`summary.frbs`

and`plotMF`

to show a summary about an`frbs-object`

, and to plot the shapes of the membership functions.Exporting an FRBS model to the frbsPMML format can be done by executing

`frbsPMML`

and`write.frbsPMML`

. The frbsPMML format is a universal framework adopted from the Predictive Model Markup Language (PMML) format. Then, in order to consume/import the frbsPMML format to an FRBS model, we call`read.frbsPMML`

.

To get started with the package, the user can have a look at some examples included in
the documentation of the functions `frbs.learn`

and `frbs.gen`

for generating models and
`predict`

for the prediction phase.

Also, there are many demos that ship with the package. To get a list of them, type:

`demo()`

Then, to start a demo, type `demo(<demo_name_here>)`

. All the demos are present as
R scripts in the package sources in the `"demo"`

subdirectory. Note that
some of them may take quite a long time which depends on specification hardwares.

Currently, there are the following demos available:

Regression using the Gas Furnance dataset:

`demo(WM.GasFur)`

,
`demo(SBC.GasFur)`

,
`demo(ANFIS.GasFur)`

,

`demo(FS.HGD.GasFur)`

,
`demo(DENFIS.GasFur)`

,
`demo(HyFIS.GasFur)`

,

`demo(FIR.DM.GasFur)`

,
`demo(GFS.FR.MOGUL.GasFur)`

,

`demo(GFS.THRIFT.GasFur)`

,
`demo(GFS.LT.RS.GasFur)`

.

Regression using the Mackey-Glass dataset:

`demo(WM.MG1000)`

,
`demo(SBC.MG1000)`

,
`demo(ANFIS.MG1000)`

,

`demo(FS.HGD.MG1000)`

,
`demo(DENFIS.MG1000)`

,
`demo(HyFIS.MG1000)`

,

`demo(GFS.THRIFT.MG1000)`

,
`demo(FIR.DM.MG1000)`

,

`demo(GFS.FR.MOGUL.MG1000)`

,
`demo(GFS.LT.RS.MG1000)`

.

Classification using the Iris dataset:

`demo(FRBCS.W.Iris)`

,
`demo(FRBCS.CHI.Iris)`

,
`demo(GFS.GCCL.Iris)`

,

`demo(FH.GBML.Iris)`

,
`demo(SLAVE.Iris)`

.

Generating FRBS model without learning process:

`demo(FRBS.Mamdani.Manual)`

,
`demo(FRBS.TSK.Manual)`

,
`demo(FRBS.Manual)`

.

Exporting/importing to/from frbsPMML:

`demo(WM.GasFur.PMML)`

,
`demo(ANFIS.GasFur.PMML)`

,
`demo(GFS.GCCL.Iris.PMML)`

.

The Gas Furnance data and Mackey-Glass data are included in the package,
please see `frbsData`

. The Iris data is the standard Iris dataset that
ships with R.

Also have a look at the package webpage http://sci2s.ugr.es/dicits/software/FRBS, where we provide a more extensive introduction as well as additional explanations of the procedures.

Lala Septem Riza lala.s.riza@decsai.ugr.es,

Christoph Bergmeir c.bergmeir@decsai.ugr.es,

Francisco Herrera herrera@decsai.ugr.es,

and Jose Manuel Benitez j.m.benitez@decsai.ugr.es

DiCITS Lab, SCI2S group, DECSAI, University of Granada.

http://sci2s.ugr.es/dicits/, http://sci2s.ugr.es

A. Guazzelli, M. Zeller, W.C. Lin, and G. Williams., "pmml: An open standard for sharing models", The R Journal, Vol. 1, No. 1, pp. 60-65 (2009).

C.C. Lee, "Fuzzy Logic in control systems: Fuzzy logic controller part I", IEEE Trans. Syst., Man, Cybern., vol. 20, no. 2, pp. 404 - 418 (1990).

C.C. Lee, "Fuzzy Logic in control systems: Fuzzy logic controller part II", IEEE Trans. Syst., Man, Cybern., vol. 20, no. 2, pp. 419 - 435 (1990).

E.H. Mamdani and S. Assilian, "An experiment in linguistic synthesis with a fuzzy logic controller," International Journal of Man Machine Studies, vol. 7, no. 1, pp. 1 - 13 (1975).

W. Pedrycz, "Fuzzy Control and Fuzzy Systems," New York: Wiley (1989).

L.S. Riza, C. Bergmeir, F. Herrera, and J.M. Benitez, "frbs: Fuzzy Rule-Based Systems for Classification and Regression in R," Journal of Statistical Software, vol. 65, no. 6, pp. 1 - 30 (2015).

M. Sugeno and G.T. Kang, "Structure identification of fuzzy model," Fuzzy Sets Syst., vol. 28, pp. 15 - 33 (1988).

T. Takagi and M. Sugeno, "Fuzzy identification of systems and its application to modelling and control", IEEE Transactions on Systems, Man and Cybernetics, vol. 15, no. 1, pp. 116 - 132 (1985).

L.A. Zadeh, "Fuzzy sets", Information and Control, vol. 8, pp. 338 - 353 (1965).

`frbs.learn`

, `frbs.gen`

, `frbsPMML`

, and `predict`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | ```
##################################
## I. Regression Problem
## In this example, we are using the gas furnace dataset that
## contains two input and one output variables.
##################################
## Input data: Using the Gas Furnace dataset
## then split the data to be training and testing datasets
data(frbsData)
data.train <- frbsData$GasFurnance.dt[1 : 204, ]
data.tst <- frbsData$GasFurnance.dt[205 : 292, 1 : 2]
real.val <- matrix(frbsData$GasFurnance.dt[205 : 292, 3], ncol = 1)
## Define interval of data
range.data <-apply(data.train, 2, range)
## Set the method and its parameters,
## for example, we use Wang and Mendel's algorithm
method.type <- "WM"
control <- list(num.labels = 15, type.mf = "GAUSSIAN", type.defuz = "WAM",
type.tnorm = "MIN", type.snorm = "MAX", type.implication.func = "ZADEH",
name = "sim-0")
## Learning step: Generate an FRBS model
object.reg <- frbs.learn(data.train, range.data, method.type, control)
## Predicting step: Predict for newdata
res.test <- predict(object.reg, data.tst)
## Display the FRBS model
summary(object.reg)
## Plot the membership functions
plotMF(object.reg)
##################################
## II. Classification Problem
## In this example, we are using the iris dataset that
## contains four input and one output variables.
##################################
## Input data: Using the Iris dataset
data(iris)
set.seed(2)
## Shuffle the data
## then split the data to be training and testing datasets
irisShuffled <- iris[sample(nrow(iris)), ]
irisShuffled[, 5] <- unclass(irisShuffled[, 5])
tra.iris <- irisShuffled[1 : 105, ]
tst.iris <- irisShuffled[106 : nrow(irisShuffled), 1 : 4]
real.iris <- matrix(irisShuffled[106 : nrow(irisShuffled), 5], ncol = 1)
## Define range of input data. Note that it is only for the input variables.
range.data.input <- apply(iris[, -ncol(iris)], 2, range)
## Set the method and its parameters. In this case we use FRBCS.W algorithm
method.type <- "FRBCS.W"
control <- list(num.labels = 7, type.mf = "GAUSSIAN", type.tnorm = "MIN",
type.snorm = "MAX", type.implication.func = "ZADEH")
## Learning step: Generate fuzzy model
object.cls <- frbs.learn(tra.iris, range.data.input, method.type, control)
## Predicting step: Predict newdata
res.test <- predict(object.cls, tst.iris)
## Display the FRBS model
summary(object.cls)
## Plot the membership functions
plotMF(object.cls)
#################################################
## III. Constructing an FRBS model from human expert.
## In this example, we only consider the Mamdani model for regression. However,
## other models can be done in the same way.
## Note:
## In the examples, let us consider four input and one output variables.
#################################################
## Define a matrix representing shape and parameters of membership functions of input variables.
## The matrix has 5 rows where the first row represent the type of the membership function whereas
## others are values of its parameters.
## Detailed explanation can be seen in the fuzzifier function to construct the matrix.
varinp.mf <- matrix(c(2, 0, 20, 40, NA, 4, 20, 40, 60, 80, 3, 60, 80, 100, NA,
2, 0, 35, 75, NA, 3, 35, 75, 100, NA,
2, 0, 20, 40, NA, 1, 20, 50, 80, NA, 3, 60, 80, 100, NA,
2, 0, 20, 40, NA, 4, 20, 40, 60, 80, 3, 60, 80, 100, NA),
nrow = 5, byrow = FALSE)
## Define number of linguistic terms of input variables.
## Suppose, we have 3, 2, 3, and 3 numbers of linguistic terms
## for the first, second, third and fourth variables, respectively.
num.fvalinput <- matrix(c(3, 2, 3, 3), nrow=1)
## Give the names of the linguistic terms of each input variables.
varinput.1 <- c("low", "medium", "high")
varinput.2 <- c("yes", "no")
varinput.3 <- c("bad", "neutral", "good")
varinput.4 <- c("low", "medium", "high")
names.varinput <- c(varinput.1, varinput.2, varinput.3, varinput.4)
## Set interval of data.
range.data <- matrix(c(0, 100, 0, 100, 0, 100, 0, 100, 0, 100), nrow = 2)
## Define inference parameters.
## Detailed information about values can be seen in the inference function.
type.defuz <- "WAM"
type.tnorm <- "MIN"
type.snorm <- "MAX"
type.implication.func <- "ZADEH"
## Give the name of simulation.
name <- "Sim-0"
## Provide new data for testing.
newdata<- matrix(c(25, 40, 35, 15, 45, 75, 78, 70), nrow = 2, byrow = TRUE)
## the names of variables
colnames.var <- c("input1", "input2", "input3", "input4", "output1")
## Define number of linguistic terms of output variable.
## In this case, we set the number of linguistic terms to 3.
num.fvaloutput <- matrix(c(3), nrow = 1)
## Give the names of the linguistic terms of the output variable.
varoutput.1 <- c("bad", "neutral", "good")
names.varoutput <- c(varoutput.1)
## Define the shapes and parameters of the membership functions of the output variables.
varout.mf <- matrix(c(2, 0, 20, 40, NA, 4, 20, 40, 60, 80, 3, 60, 80, 100, NA),
nrow = 5, byrow = FALSE)
## Set type of model which is "MAMDANI".
type.model <- "MAMDANI"
## Define the fuzzy IF-THEN rules;
## In this example we are using the Mamdani model
## Note: e.g.,
## "a1", "and", "b1, "->", "e1" means that
## "IF inputvar.1 is a1 and inputvar.2 is b1 THEN outputvar.1 is e1"
## Make sure that each rule has a "->" sign.
rule <- matrix(
c("low", "and", "yes", "and", "bad", "and", "low", "->", "bad",
"medium", "and", "no", "and", "neutral", "and", "medium", "->", "neutral",
"high", "and", "no", "and", "neutral", "and", "low", "->", "good"),
nrow = 3, byrow = TRUE)
## Generate a fuzzy model with frbs.gen.
object <- frbs.gen(range.data, num.fvalinput, names.varinput,
num.fvaloutput, varout.mf, names.varoutput, rule,
varinp.mf, type.model, type.defuz, type.tnorm,
type.snorm, func.tsk = NULL, colnames.var, type.implication.func, name)
## Plot the membership function.
plotMF(object)
## Predicting using new data.
res <- predict(object, newdata)$predicted.val
#################################################
## IV. Specifying an FRBS model in the frbsPMML format.
## other examples can be seen in the frbsPMML function.
#################################################
## Input data
data(frbsData)
data.train <- frbsData$GasFurnance.dt[1 : 204, ]
data.fit <- data.train[, 1 : 2]
data.tst <- frbsData$GasFurnance.dt[205 : 292, 1 : 2]
real.val <- matrix(frbsData$GasFurnance.dt[205 : 292, 3], ncol = 1)
range.data<-matrix(c(-2.716, 2.834, 45.6, 60.5, 45.6, 60.5), nrow = 2)
## Set the method and its parameters
method.type <- "WM"
control <- list(num.labels = 3, type.mf = "GAUSSIAN", type.defuz = "WAM",
type.tnorm = "MIN", type.snorm = "MAX",
type.implication.func = "ZADEH", name="sim-0")
## Generate fuzzy model
object <- frbs.learn(data.train, range.data, method.type, control)
## 2. Constructing the frbsPMML format
frbsPMML(object)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.