我一直在尝试使用R Statistical软件来构建Takagi Sugeno模糊系统。使用R包' frbs'我已经设法按照演示文件中的示例设置了FIS的大部分组件。不幸的是,我遇到了一个问题: validate.params(object,newdata)出错: 请检查您的num.labels参数 我一直试图预测一些价值,我不知道这个剧本有什么问题。当我评论最后一行时,一切似乎都没问题,但只有一个情节正在绘制。
# rm(list=ls()) # not generally appreciated
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), 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)
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, varout.mf=NULL, names.varoutput, 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)
失败的测试见int x = 10;
while (x < 10) {
System.out.println("Never gets here");
}
代码:
validate.params
当我在frbs:::validate.params
....
else if (object$type.model == c("TSK")) {
if (ncol(object$num.labels) != (ncol(object$range.data.ori) -
1)) {
stop("Please check your num.labels parameters")
帮助页面上的示例中运行代码时,我会看到:
frbs.gen
然而,有了你的例子,我看到了:
> res <- predict(object, newdata)$predicted.val
> object$range.data.ori
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 100 100 100 100 100
> object$num.labels
[,1] [,2] [,3] [,4]
[1,] 3 2 3 3
所以你的'对象'对象不是根据包作者的期望创建的。似乎错误应该在流程的早期发现,而不是让它由> object$num.labels
[,1] [,2]
[1,] 2 2
> object$range.data.ori
[,1] [,2]
[1,] -1.5 -1.5
[2,] 1.5 1.5
发出信号。