fuzzy logic - Takagi Sugeno system in R with frbs something wrong with rulebase -
i've been trying use r statistical software build takagi sugeno fuzzy system. using r package frbs i've managed set of components of fis following example in demo files. unfortunately, i've hit problem:
error in rule[, (4 * i), drop = false] : subscript out of bounds
in line:
res <- predict(object, newdata)$predicted.val i have no idea wrong in script. rules should good, same use in matlab script , works. in documentation , examples in frbs library.
#rm(list=ls()) library(frbs) varinp.mf <- matrix(c( 5, -1, 0.8493, na, na, 5, 1, 0.8493, na, na, 5, -1, 0.8493, na, na, 5, 1, 0.8493, na, na), nrow = 5, byrow = false) num.fvalinput <- matrix(c(2,2), nrow=1) x1 <- c("a1","a2") x2 <- c("b1","b2") names.varinput <- c(x1, x2) range.data <- matrix(c(-1.5,1.5, -1.5, 1.5, -1.5, 1.5), nrow=2) type.defuz <- "5" type.tnorm <- "min" type.snorm <- "max" type.implication.func <- "min" name <- "przykład" newdata <- matrix(c(-0.6, 0.3), ncol = 2, byrow = true) colnames.var <- c("x1", "x2") type.model <- "tsk" func.tsk <- matrix(c(1, 1, 1, 2, 1, 0, 1, -2, -1, -1, 0.5, -2), nrow = 4, byrow = true) # r1 <- c("a1","and","b1","->") # r2 <- c("a1","and","b2", "->") # r3 <- c("a2","and","b1", "->") # r4 <- c("a2","and","b2", "->") # rule <- list(r1,r2,r3,r4) rule <- matrix(c("a1","and","b1","->", "a1","and","b2","->", "a2","and","b1","->", "a2","and","b2","->"), nrow = 4, byrow = true) object <- frbs.gen( range.data, num.fvalinput, names.varinput, num.fvaloutput=null, varout.mf=null, names.varoutput=null, rule, varinp.mf, type.model, type.defuz, type.tnorm, type.snorm, func.tsk, colnames.var, type.implication.func) plotmf(object) res <- predict(object, newdata)$predicted.val i see wrong in object$rule don't know how fix it.
according documentation: colnames.var list of names of input , output variables. add output hat example colnames.var <- c("x1", "x2","o1").
Comments
Post a Comment