Type: | Package |
Title: | Fuzzy Inference System Design and Optimization |
Version: | 1.1.4 |
Author: | Serge Guillaume [aut], Brigitte Charnomordic [aut], Jean-Luc Lablée [aut, cre], Hazaël Jones [ctb], Lydie Desperben [ctb], INRAE [cph] (National Research Institute for Agriculture, Food and Environment, France) |
Maintainer: | Jean-Luc Lablée <jean-luc.lablee@inrae.fr> |
URL: | https://www.fispro.org |
Description: | Fuzzy inference systems are based on fuzzy rules, which have a good capability for managing progressive phenomenons. This package is a basic implementation of the main functions to use a Fuzzy Inference System (FIS) provided by the open source software 'FisPro' https://www.fispro.org. 'FisPro' allows to create fuzzy inference systems and to use them for reasoning purposes, especially for simulating a physical or biological system. |
License: | CeCILL version 2 | CECILL-2.1 [expanded from: CeCILL] |
Encoding: | UTF-8 |
Depends: | R (≥ 3.6.0) |
Imports: | methods, utils, Rdpack, Rcpp (≥ 1.0.0) |
RdMacros: | Rdpack |
NeedsCompilation: | yes |
LinkingTo: | Rcpp, BH |
Suggests: | testthat, rlang, knitr, rmarkdown |
RoxygenNote: | 7.2.3 |
VignetteBuilder: | knitr |
Packaged: | 2023-03-16 08:47:52 UTC; jllablee |
Repository: | CRAN |
Date/Publication: | 2023-03-16 09:30:02 UTC |
FisPro package
Description
This package is a basic implementation of the main functions to use a "Fuzzy Inference System" that can be used for reasoning purposes, especially for simulating a physical or biological system. It is derived from the FisPro open source software. Fuzzy inference systems are briefly described in the Fuzzy Logic Elementary Glossary. They are based on fuzzy rules, which have a good capability for managing progressive phenomenons. Fuzzy logic, since the pioneer work by Zadeh, has proven to be a powerful interface between symbolic and numerical spaces. One of the reasons for this success is the ability of fuzzy systems to incorporate human expert knowledge with its nuances, as well as to express the behaviour of the system in an interpretable way for humans. Another reason is the possibility of designing data-driven FIS to make the most of available data.
To design a fuzzy system that can be handled by this package the user can use the FisPro software. If needed, the package can be extended to other functions.
All the mentioned publications are available from the FisPro web site.
Enjoy FisPro!
Author(s)
FisPro Team contact@fispro.org
References
Guillaume S, Charnomordic B (2011). “Learning interpretable Fuzzy Inference Systems with FisPro.” International Journal of Information Sciences, 181(20), 4409-4427. doi:10.1016/j.ins.2011.03.025, Special Issue on Interpretable Fuzzy Systems.
Guillaume S, Charnomordic B (2012). “Fuzzy Inference Systems: an integrated modelling environment for collaboration between expert knowledge and data using FisPro.” Expert Systems with Applications, 39(10), 8744-8755. doi:10.1016/j.eswa.2012.01.206.
See Also
Class "Fis"
Description
Class to manage a Fis "Fuzzy Inference System"
Fields
name
character vector, The name of the Fis
conjunction
character vector, The conjunction operator of rules in the Fis
Allowed values are: "min" (the default), "prod" or "luka"
Constructors
Fis()
-
The default constructor to build an empty Fis
The Fis is initialized with "min" conjunction and empty name
The design must be completed using the available functions to add inputs, outputs and rules before it can be used for inference- return:
Fis object
Fis(fis_file)
-
The constructor to build a Fis from a configuration file
The configuration file can be designed using the FisPro open source software
Methods
input_size()
-
- return:
integer value, The number of inputs in the Fis
add_input(input)
-
- argument:
input
FisIn object, The input to add in the Fis
- argument:
get_input(input_index)
get_inputs()
-
Get all inputs in the Fis
output_size()
-
- return:
integer value, The number of outputs in the Fis
add_output(output)
-
- argument:
output
FisOut object, The output to add in the Fis
- argument:
get_output(output_index)
get_outputs()
-
Get all outputs in the Fis
rule_size()
-
- return:
integer value, The number of rules in the Fis
add_rule(rule)
-
- argument:
rule
Rule object, The rule to add in the Fis
- argument:
get_rule(rule_index)
get_rules()
-
Get all rules in the Fis
infer(data)
-
Infers all outputs
- argument:
data
numeric vector, matrix or data.frame, The input data or dataset to infer (the vector length or the number of columns must be equal to the number of inputs)
- return:
- argument:
infer_output(data, output_index)
-
Infers a single output
- argument:
data
numeric vector, matrix or data.frame, The input data or dataset to infer (the vector length or the number of columns must be equal to the number of inputs)
- argument:
output_index
integer value, The index (1-based index) of the output to infer
- return:
numeric value or vector (in case of 2D input data)
- argument:
See Also
Fuzzy Logic Elementary Glossary
Examples
# build a Fis from a configuration file
fis_file <- system.file("extdata", "test.fis", package = "FisPro")
fis <- NewFis(fis_file)
# infers all outputs
inferred <- fis$infer(c(0.25, 0.75))
# infers first output
inferred_output1 <- fis$infer_output(c(0.25, 0.75), 1)
# infers second output
inferred_output2 <- fis$infer_output(c(0.25, 0.75), 2)
# infers test_data dataset
test_file <- system.file("extdata", "test_data.csv", package = "FisPro")
dataset <- read.csv(test_file)
inferred_dataset <- fis$infer(dataset)
########################################################################
# or build a Fis from scratch
fis <- NewFis()
fis$name <- "foo"
# build the first input
fisin1 <- NewFisIn(0, 1)
fisin1$name <- "input1"
fisin1$add_mf(NewMfTrapezoidalInf(0, 1))
fisin1$add_mf(NewMfTrapezoidalSup(0, 1))
fis$add_input(fisin1)
# build the second input
fisin2 <- NewFisIn(0, 1)
fisin2$name <- "input2"
fisin2$add_mf(NewMfTrapezoidalInf(0, 0.5))
fisin2$add_mf(NewMfTriangular(0, 0.5, 1))
fisin2$add_mf(NewMfTrapezoidalSup(0.5, 1))
fis$add_input(fisin2)
# build an output
fisout <- NewFisOutCrisp(0, 1)
fisout$name <- "output"
fis$add_output(fisout)
# add rules to the Fis
fis$add_rule(NewRule(c(1, 2), 0))
fis$add_rule(NewRule(c(2, 0), 1))
Class "Fisin"
Description
Class to manage a Fis input
Fields
name
character vector, The name of the input
Constructors
FisIn()
-
The default constructor to build an empty input with the default range [0, 1]
- return:
FisIn object
FisIn(minimum, maximum)
-
The constructor to build an empty input
FisIn(number_of_mfs, minimum, maximum)
-
The constructor to build an input with a regular standardized fuzzy partition
FisIn(breakpoints, minimum, maximum)
-
The constructor to build an input with an irregular standardized fuzzy partition
Methods
range()
-
- return:
numeric vector, The range of the input (min max values)
mf_size()
-
- return:
integer value, The number of Mfs in the input partition
add_mf(mf)
-
Add an Mf in the input partition
- argument:
mf
Mf object, The Mf to add
- argument:
get_mf(mf_index)
get_mfs()
-
Get all mfs in the input
is_standardized()
-
- return:
logical value,
TRUE
if the input is a standardized fuzzy partition,FALSE
otherwise
See Also
Fuzzy Logic Elementary Glossary
Examples
input <- NewFisIn(0, 2)
input$name <- "foo"
input$add_mf(NewMfTrapezoidalInf(0, 1))
input$add_mf(NewMfTriangular(0, 1, 2))
input$add_mf(NewMfTrapezoidalSup(1, 2))
Class "FisOut"
Description
The base class of Fis output (cannot be instantiate)
Use derived classes FisOutCrisp or FisOutFuzzy
Fields
name
character vector, The name of the output
Methods
range()
-
- return:
numeric vector, The range of the output (min max values)
Class "FisOutCrisp"
Description
Class to manage a Fis crisp output
Fields
defuzzification
character vector, The defuzzification operator of the crisp output
Allowed values are: "sugeno" (the default) or "MaxCrisp"disjunction
character vector, The disjunction operator of the crisp output
Allowed values are: "max" (the default) or "sum"
Inherits
FisOutCrisp class inherits all fields and methods of FisOut class
Constructors
FisOutCrisp()
-
The default constructor to build a crisp output with the default range [0, 1]
- return:
FisOutCrisp object
FisOutCrisp(minimum, maximum)
-
The constructor to build a crisp output
- argument:
minimum
numeric value, The minimum range value of the output
- argument:
maximum
numeric value, The maximum range value of the output
- return:
FisOutCrisp object
- argument:
See Also
Fuzzy Logic Elementary Glossary
Examples
output <- NewFisOutCrisp(0, 1)
output$name <- "foo"
output$defuzzification <- "sugeno"
output$disjunction <- "max"
Class "FisOutFuzzy"
Description
Class to manage a Fis fuzzy output
Fields
defuzzification
character vector, The defuzzification operator of the fuzzy output
Allowed values are: "sugeno" (the default) "MeanMax", or "area"disjunction
character vector, The disjunction operator of the fuzzy output
Allowed values are: "max" (the default) or "sum"
Inherits
FisOutFuzzy class inherits all fields and methods of FisOut class
Constructors
FisOutFuzzy()
-
The default constructor to build a fuzzy output with the default range [0, 1]
- return:
FisOutFuzzy object
FisOutFuzzy(minimum, maximum)
-
The constructor to build a fuzzy output
- argument:
minimum
numeric value, The minimum range value of the output
- argument:
maximum
numeric value, The maximum range value of the output
- return:
FisOutFuzzy object
- argument:
FisOutFuzzy(number_of_mfs, minimum, maximum)
-
The constructor to build a fuzzy with a regular standardized fuzzy partition
- argument:
number_of_mfs
integer value, The number of Mfs in the fuzzy partition
- argument:
minimum
numeric value, The minimum range value of the output
- argument:
maximum
numeric value, The maximum range value of the output
- return:
FisOutFuzzy object
- argument:
FisOutFuzzy(breakpoints, minimum, maximum)
-
The constructor to build a fuzzy with an irregular standardized fuzzy partition
- argument:
breakpoints
numeric vector, The breakpoint values (sorted in ascending order) of the Mfs in the fuzzy partition
- argument:
minimum
numeric value, The minimum range value of the output
- argument:
maximum
numeric value, The maximum range value of the output
- return:
FisOutFuzzy object
- argument:
Methods
mf_size()
-
- return:
integer value, The number of Mfs in the output partition
add_mf(mf)
-
Add an Mf in the output partition
- argument:
mf
Mf object, The Mf to add
- argument:
get_mf(mf_index)
get_mfs()
-
Get all mfs in the output
is_standardized()
-
- return:
logical value,
TRUE
if the output is a standardized fuzzy partition,FALSE
otherwise
See Also
Fuzzy Logic Elementary Glossary
Examples
output <- NewFisOutFuzzy(0, 2)
output$name <- "foo"
output$defuzzification <- "sugeno"
output$disjunction <- "max"
output$add_mf(NewMfTrapezoidalInf(0, 1))
output$add_mf(NewMfTriangular(0, 1, 2))
output$add_mf(NewMfTrapezoidalSup(1, 2))
Deprecated classes in package FisPro.
Description
The classes listed below are deprecated and will be removed in future version.
Alternative classes with similar functionality are also mentioned.
Help pages for deprecated functions are available at help("<class>-deprecated")
.
Deprecated classes
For fis, use Fis instead
For mf, use Mf instead
For mf_triangular, use MfTriangular instead
For mf_trapezoidal_inf, use MfTrapezoidalInf instead
For mf_trapezoidal_sup, use MfTrapezoidalSup instead
For mf_trapezoidal, use MfTrapezoidal instead
See Also
fis-deprecated
mf-deprecated
mf_triangular-deprecated
mf_trapezoidal_inf-deprecated
mf_trapezoidal_sup-deprecated
mf_trapezoidal-deprecated
Class "Mf"
Description
The base class of all "membership function" classes (cannot be instantiate)
Use derived classes MfTriangular, MfTrapezoidal, MfTrapezoidalInf or MfTrapezoidalSup
Fields
label
character vector, The label of the membership function
Methods
degree(value)
-
Get the membership degree
See Also
Fuzzy Logic Elementary Glossary
Class "MfTrapezoidal"
Description
Class to manage a trapezoidal membership function
Inherits
MfTrapezoidal class inherits all fields and methods of Mf class
Constructors
MfTrapezoidal(lower_support, lower_kernel, upper_kernel, upper_support)
-
- argument:
lower_support
numeric lower value of support
- argument:
lower_kernel
numeric lower value of kernel
- argument:
upper_kernel
numeric upper value of kernel
- argument:
upper_support
numeric upper value of support
- return:
MfTrapezoidal object
- argument:
See Also
Examples
mf <- NewMfTrapezoidal(0, 1, 2, 3)
mf$degree(0.5)
Class "MfTrapezoidalInf"
Description
Class to manage a trapezoidal inf membership function
Inherits
MfTrapezoidalInf class inherits all fields and methods of Mf class
Constructors
MfTrapezoidalInf(upper_kernel, upper_support)
-
- argument:
upper_kernel
numeric upper value of kernel
- argument:
upper_support
numeric upper value of support
- return:
MfTrapezoidalInf object
- argument:
See Also
Examples
mf <- NewMfTrapezoidalInf(0, 1)
mf$degree(0.5)
Class "MfTrapezoidalSup"
Description
Class to manage a trapezoidal sup membership function
Inherits
MfTrapezoidalSup class inherits all fields and methods of Mf class
Constructors
MfTrapezoidalSup(lower_support, lower_kernel)
-
- argument:
lower_support
numeric lower value of support
- argument:
lower_kernel
numeric lower value of kernel
- return:
MfTrapezoidalSup object
- argument:
See Also
Examples
mf <- NewMfTrapezoidalSup(0, 1)
mf$degree(0.5)
Class "MfTriangular"
Description
Class to manage a triangular membership function
Inherits
MfTriangular
class inherits all fields and methods of Mf class
Constructors
MfTriangular(lower_support, kernel, upper_support)
-
- argument:
lower_support
numeric lower value of support
- argument:
kernel
numeric value of kernel
- argument:
upper_support
numeric upper value of support
- return:
MfTriangular object
- argument:
See Also
Examples
mf <- NewMfTriangular(0, 1, 2)
mf$degree(0.5)
Create object of class "Fis"
Description
Function to create object of class Fis
Usage
NewFis(...)
Arguments
... |
arguments of Fis constructor |
Value
Fis object
Create object of class "FisIn"
Description
Function to create object of class FisIn
Usage
NewFisIn(...)
Arguments
... |
arguments of FisIn constructor |
Value
FisIn object
Create object of class "FisOutCrisp"
Description
Function to create object of class FisOutCrisp
Usage
NewFisOutCrisp(...)
Arguments
... |
arguments of FisOutCrisp constructor |
Value
FisOutCrisp object
Create object of class "FisOutFuzzy"
Description
Function to create object of class FisOutFuzzy
Usage
NewFisOutFuzzy(...)
Arguments
... |
arguments of FisOutFuzzy constructor |
Value
FisOutFuzzy object
Create object of class "MfTrapezoidal"
Description
Function to create object of class MfTrapezoidal
Usage
NewMfTrapezoidal(...)
Arguments
... |
arguments of MfTrapezoidal constructor |
Value
MfTrapezoidal object
Create object of class "MfTrapezoidalInf"
Description
Function to create object of class MfTrapezoidalInf
Usage
NewMfTrapezoidalInf(...)
Arguments
... |
arguments of MfTrapezoidalInf constructor |
Value
MfTrapezoidalInf object
Create object of class "MfTrapezoidalSup"
Description
Function to create object of class MfTrapezoidalSup
Usage
NewMfTrapezoidalSup(...)
Arguments
... |
arguments of MfTrapezoidalSup constructor |
Value
MfTrapezoidalSup object
Create object of class "MfTriangular"
Description
Function to create object of class MfTriangular
Usage
NewMfTriangular(...)
Arguments
... |
arguments of MfTriangular constructor |
Value
MfTriangular object
Create object of class "Rule"
Description
Function to create object of class Rule
Usage
NewRule(...)
Arguments
... |
arguments of Rule constructor |
Value
Rule object
Class "Rule"
Description
Class to manage a Fis rule
Fields
premises
integer vector, The premises of the rule
A premise is the 1-based index of MF in the FisIn
0 means the input is not taken into account for this rule, i.e. the rule is incomplete
The vector length must be equal to the number of inputs in the Fisconclusions
numeric vector, The conclusions of the rule
A conclusion is a numeric value for crisp output FisOutCrisp, or the 1-based index of MF in the fuzzy output FisOutFuzzy
The vector length must be equal to the number of outputs in the Fis
Constructors
Rule()
-
The default constructor to build an empty rule
The rule is initialized with empty premises and conclusions- return:
Rule object
Rule(premises, conclusions)
-
The constructor to build a rule
See Also
Fuzzy Logic Elementary Glossary
Examples
rule1 <- NewRule()
rule1$premises <- c(1, 2, 0)
rule1$conclusions <- c(1, 2)
rule2 <- NewRule(c(2, 1, 1), c(2, 1))
Deprecated class "fis"
Description
The fis
class is deprecated and will be removed in future version, use Fis instead
Methods
infer_output(data, output_index)
-
WARNING !!! the
output_index
is now 1-based indexed in Fis, was 0-based indexed in fis
See Also
Deprecated class "mf"
Description
The mf
class is deprecated and will be removed in future version, use Mf instead
See Also
Deprecated class "mf_trapezoidal"
Description
The mf_trapezoidal
class is deprecated and will be removed in future version, use MfTrapezoidal instead
See Also
Deprecated class "mf_trapezoidal_inf"
Description
The mf_trapezoidal_inf
class is deprecated and will be removed in future version, use MfTrapezoidalInf instead
See Also
Deprecated class "mf_trapezoidal_sup"
Description
The mf_trapezoidal_sup
class is deprecated and will be removed in future version, use MfTrapezoidalSup instead
See Also
Deprecated class "mf_triangular"
Description
The mf_triangular
class is deprecated and will be removed in future version, use MfTriangular instead