3

I'm using frbs package in R on my data set using 5-fold stratified cross validation. I've implemented stratified CV. I use GFS.GCCL method for frbs.learn function in each fold and predict the result using test data. I get this error as well as 30 equal warning messages:

Error: object 'temp.rule.degree' not found

Warning: In max(MF.temp[m, ], na.rm = TRUE) : no non-missing arguments to max; returning -Inf

My code is written in below:

    library(frbs)
    data<-read.csv(file.address)
    data[,30] <- unclass(data[,30]) #column 30 has the class of samples
    data <- data[,c(1,14,20,26,27, 30)] # I choose to have 5 attr. since
                                         #my data is high dimensional    

    k <- 5 # 5-fold 
    seed <- 1
    folds <- strf.cv(data, k, seed) #stratification function for CV


    range.data.inp <- matrix(apply(data[,-ncol(data)], 2, range), nrow=2)

    data<-norm.data(as.matrix(data[,-ncol(data)]),range.data.
            inp,min.scale = 0.1, max.scale = 1)

    ctrl <- list(popu.size = 30, num.class = 2, num.labels= 3,
            persen_cross = 0.9, max.gen = 200, persen_mutant = 0.3,
         name="sim-1")
    for(i in 1:k){

    str <- paste("fold",i)
    print(str)
    test.ind <- folds[[str]]
    test.data <- data[test.ind,]
    train.data <- data[-test.ind,]

    obj <- frbs.learn(train.data , method.type="GFS.GCCL",
                 range.data.inp , ctrl)


    pred <- predict(obj, test.data)
    print("Predicted classes:")
    print(pred)
    }

I don't have any idea about error and warnings. Please let me know what I should do.

Pegah
  • 121
  • 1
  • 12

3 Answers3

1

I've had similar problem (and others) trying to reproduce the SLAVE learning starting with the iris example data. I had 2 format items to solve before being able to run this with my artifical data:

  • my dataframe import was giving me integer, where the learn needs at least numeric.
  • my distribution of criteria was not flat. When I flattened the distribution (3 values so n/3 samples per value) everything went fine.

That's all I know. Hope it helps.

Vasfed
  • 18,013
  • 10
  • 47
  • 53
Pilip38
  • 11
  • 2
1

I encountered the same issue when I was running SLAVE and GFS.GCCL. When I was looking at the source code of the library. I found that in frbs.learn(), each method has an implementation to calculate the range of input data. So, I think it might be a problem with the range of input data. For example, in GFS.GCCL, in the source code, for setting the parameters, it looks like this:

range.data.input <- range.data
data.train.ori <- data.train
popu.size <- control$popu.size
persen_cross <- control$persen_cross
persen_mutant <- control$persen_mutant
max.gen <- control$max.gen
name <- control$name
n.labels <- control$num.labels
n.class <- control$num.class

num.labels <- matrix(rep(n.labels, ncol(range.data)), nrow = 1)
num.labels <- cbind(num.labels, n.class)

## normalize range of data and data training
range.data.norm <- range.data.input
range.data.norm[1, ] <- 0
range.data.norm[2, ] <- 1   
range.data.input.ori <- range.data.input
data.tra.norm <- norm.data(data.train[, 1 : ncol(data.train) - 1], range.data.input, min.scale = 0, max.scale = 1)
data.train <- cbind(data.tra.norm, matrix(data.train[, ncol(data.train)], ncol = 1))

in the first line, range.data is either coming from your specification nor the default setting of frbs.learn(). For the default setting, it gets the max and min for each row. In the source code:

range.data <- rbind(dt.min, dt.max)

After that, the range of data taken by the GFS.GCCL is

range.data.norm <- range.data.input
range.data.norm[1, ] <- 0
range.data.norm[2, ] <- 1

which is between 0 and 1. The GFS.GCCL is also taken the range.data.input as parameter. So, it takes both range.data.norm and range.data.input.

Therefore, I think if internally, there are some calculation corresponding to range.data.input (it needs to be set as min, max for each row), but the setting for this is actually not min and max for each row. The error is generated.

But, in summary, after I remove "range.data"from frbs.learn(), both GFS.GCCL and SLAVE work for me.

You can download the source code from here:

https://cran.r-project.org/web/packages/frbs/index.html

You can find the code for GFS.GCCL and SLAVE in:

FRBS.MainFunction.R

GFS.Methods.R

0

In addition to @Pilip38's good advice, I have three other ideas that have fixed similar errors for me while working with the frbs package.

  1. Most important: Make sure your output variable is never equal to 0. It looks like you have a binary output variable so I am hoping just adding 1 to it so it is 1/2 instead of 0/1 will work.
  2. Try setting your range.data.inp matrix to be all 0's in the first row and all 1's in the second. Naturally it's better to have a tighter range but it may be causing your bug.
  3. Try decreasing the number of labels to 2.

It's can be a brittle procedure.

Josh Rumbut
  • 2,640
  • 2
  • 32
  • 43