我一直在尝试使用R Statistical软件来构建Takagi Sugeno模糊系统。使用R包if (jp.getCurrentToken() != JsonToken.START_ARRAY) {
throw new JsonParseException("Start array expected", jp.getCurrentLocation());
}
我已经设法按照演示文件中的示例设置了FIS的大部分组件。不幸的是,我遇到了一个问题:
规则错误[,(4 * i),drop = FALSE]:下标越界
排队:
frbs
我不知道这个脚本有什么问题。规则应该是好的,我在MATLAB脚本中使用的相同,它的工作原理。我在res <- predict(object, newdata)$predicted.val
库中的文档和示例中做了类似的事情。
frbs
我在#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
看到了一些错误,但我不知道如何修复它。
答案 0 :(得分:0)
根据文件: colnames.var 输入和输出变量的名称列表。只需像帽子一样添加输出,例如 colnames.var&lt; - c(“x1”,“x2”,“o1”)。