plotMF: The plotting function

Description Usage Arguments Examples

View source: R/FRBS.MainFunction.R

Description

This function can be used to plot the shapes of the membership functions.

Usage

1
plotMF(object)

Arguments

object

an frbs-object or a list of parameters to plot membership functions when we build the frbs model without learning. For plotting using the list, there are several parameters that must be inserted in params as follows.

  • var.mf: a matrix of membership function of input and output variables. Please see fuzzifier.

  • range.data.ori: a matrix (2 \times n) containing the range of the data, where n is the number of variables, and first and second rows are the minimum and maximum values, respectively.

  • num.labels: the number of linguistic terms of the input and output variables.

    For example: num.labels <- matrix(c(3, 3, 3), nrow = 1)

    It means we have 3 linguistic values/labels for two input variables and one output variable.

  • names.variables: a list of names of variables.

    For example: names.variables <- c("input1", "input2", "output1")

Examples

 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
## The following examples contain two different cases which are
## using an frbs-object and the manual way. 
## 
## 1. Plotting using frbs object.
data(iris)
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)

## Please take into account that the interval needed is the range of input data only.
range.data.input <- matrix(c(4.3, 7.9, 2.0, 4.4, 1.0, 6.9, 0.1, 2.5), nrow=2)

## generate the model
method.type <- "FRBCS.W"
control <- list(num.labels = 7, type.mf = 1) 
## Not run: object <- frbs.learn(tra.iris, range.data.input, method.type, control) 

## plot the frbs object
## Not run: plotMF(object)

## 2. Plotting using params.
## Define shape and parameters of membership functions of input variables.
## Please see the fuzzifier function of how to contruct the matrix.
varinp.mf <- matrix(c(2, 0, 20, 40, NA, 4, 20, 40, 60, 80, 3, 60, 80, 100, NA,
                      2, 0, 20, 40, NA, 4, 20, 40, 60, 80, 3, 60, 80, 100, NA,
                      2, 0, 20, 40, NA, 4, 20, 40, 60, 80, 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 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)
var.mf <- cbind(varinp.mf, varout.mf)
range.data <- matrix(c(0,100, 0, 100, 0, 100, 0, 100, 0, 100), nrow=2)
num.labels <- matrix(c(3,3,3,3,3), nrow = 1)
names.variables <- c("input1", "input2", "input3", "input4", "output1")

## plot the membership function.
## Not run: plotMF(object = list(var.mf = var.mf, range.data.ori = range.data, 
          num.labels = num.labels, names.variables = names.variables))
## End(Not run)

frbs documentation built on Dec. 16, 2019, 1:19 a.m.