Fis | R Documentation |
Class to manage a Fis "Fuzzy Inference System"
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"
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
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
fis_file
character vector, The filename of the Fis configuration file
Fis object
input_size()
integer value, The number of inputs in the Fis
add_input(input)
input
FisIn object, The input to add in the Fis
get_input(input_index)
input_index
integer value, The index (1-based index) of the input in the Fis
FisIn object
get_inputs()
Get all inputs in the Fis
list of FisIn objects
output_size()
integer value, The number of outputs in the Fis
add_output(output)
output
FisOut object, The output to add in the Fis
get_output(output_index)
output_index
integer value, The index (1-based index) of the output in the Fis
FisOut object
get_outputs()
Get all outputs in the Fis
list of FisOut objects
rule_size()
integer value, The number of rules in the Fis
add_rule(rule)
rule
Rule object, The rule to add in the Fis
get_rule(rule_index)
rule_index
integer value, The index (1-based index) of the rule in the Fis
Rule object
get_rules()
Get all rules in the Fis
list of Rule objects
infer(data)
Infers all outputs
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)
numeric vector or matrix (in case of 2D input data)
infer_output(data, output_index)
Infers a single output
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)
output_index
integer value, The index (1-based index) of the output to infer
numeric value or vector (in case of 2D input data)
NewFis
Fuzzy Logic Elementary Glossary
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.