作为模型结果的具有单个值的列

Column with single value as a result of a model

我正在尝试使用 frbs 包生成一个仅包含一些默认参数的模型。我没有收到任何错误,但结果是一列只有一个值(最低值)。 当我 运行 使用不同方法的相同代码时,我得到了合理的结果。

这个方法和我的代码有什么问题?

train <- iris[1 : 100, 1:4]
test <- iris[101 : 150, 1 : 3]
real <- matrix(iris[101 : 150, 4], ncol = 1)
my_range=apply(iris[,1:4],2,range)
method.type <- "ANFIS"
control <- list(num.labels = 3, max.iter = 10, step.size = 0.01, type.tnorm = "MIN", type.snorm = "MAX", type.implication.func = "ZADEH", name = "diams")
mod <- frbs.learn(train, my_range, method.type, control)
prd<- predict(mod, test)

您需要 num.labels=4(其中还包括响应变量):

control <- list(num.labels = 4, max.iter = 10, step.size = 0.01, type.tnorm = "MIN", type.snorm = "MAX", type.implication.func = "ZADEH", name = "diams")
mod <- frbs.learn(train, my_range, method.type, control)
prd<- predict(mod, newdata=test)

head(prd)
         [,1]
[1,] 1.680819
[2,] 1.422430
[3,] 1.957765
[4,] 1.693969
[5,] 1.770748
[6,] 2.262179