g.f.l g.f.l - 8 months ago 43
R Question

Column with single value as a result of a model

I am trying to to generate a model just with some default parameters with the

frbs
package. I don't get any errors but the result is a column with just one value(the lowest value).
When I run the same code for a different method I get reasonable results.

What is wrong with this method and my code?

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)

Answer

You need to have num.labels=4 (which includes the response variable also):

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